Hello: I would appreciate your feedback on whether I correctly wrote my XML. I am exporting a DataFrame and writing into a XML file. I used the ElementTree library. The DataFrame has 11 rows and 8 columns (excluding the index column).
#My schema assumption: #<list> #[<message> #<index>Some number row</index> #<date>Sample text </data> #</message>] #</list> CODE: SELECT ALL <http://www.python-forum.org/viewtopic.php?f=6&t=15261#> document = ET.Element("list") def make_message(document, row): msg = ET.SubElement(document, "message") for field in row.index: field_element = ET.SubElement(msg, field) field_element.text = row[field] return msg def add_to_document(row): return make_message(document, row) #df.apply(add_to_document, axis=0) ---> if I were to import a DataFrame stored in the variable #"df", I would simply APPLY the add_to_document function and COMBINE this into a document ET.dump(document) Thank you, in advance for your help. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor