python - Convert XML structure into a Pandas DataFrame without using a complex set of for loops -
i'm trying convert xml pandas dataframe. tried method austin taylor website without success.
here's code far:
import xml.etree.elementtree et import pandas pd xml_data = open("c:\\users\\john__000\\documents\\analytics\\anlt data wrangling\\assignments viz\/xdemo_stat.xml").read() def xml2df(xml_data): root = et.xml(xml_data) # element tree all_records = [] i, child in enumerate(root): record = {} subchild in child: record[subchild.tag] = subchild.text all_records.append(record) return pd.dataframe(all_records)
after running code, nothing happened. i'm expecting dataframe didn't work. might issue?
Comments
Post a Comment