用pandas读取komoot xml文件(gpx)

问题描述 投票:0回答:1
python pandas xml dataframe gpx
1个回答
3
投票

遵循

ValueError
指南,您需要将
namespace
传递给
read_xml
:

df = (
    pd.read_xml(
        "testfile.gpx",
        xpath=".//doc:trkseg/doc:trkpt",
        namespaces={"doc": "http://www.topografix.com/GPX/1/1"}
    )
)

输出:

print(df)

         lat       lon         ele                      time
0  60.126749  4.250254  455.735013  2023-08-20T17:42:34.674Z
1  60.126580  4.250247  455.735013  2023-08-20T17:42:36.695Z
2  60.126484  4.250240  455.735013  2023-08-20T17:44:15.112Z
© www.soinside.com 2019 - 2024. All rights reserved.