15 lines
418 B
Python
15 lines
418 B
Python
import pandas as pd
|
|
import io
|
|
|
|
print("Pandas version: ", pd.__version__)
|
|
|
|
def xml2df(xml_file):
|
|
with open(xml_file, "r") as F:
|
|
xml_data = F.read()
|
|
return pd.read_xml(io.StringIO(xml_data), parser="etree", xpath=".//component-class//feature-value")
|
|
|
|
if __name__ == "__main__":
|
|
df = xml2df("test_data.tcx")
|
|
df.assign(counter = lambda df: df.groupby('.//component/name').cumcount())
|
|
|
|
print(df) |