【发布时间】:2022-01-25 17:06:11
【问题描述】:
示例 Xml 内容:
<?xml version="1.0" encoding="UTF-8"?><logs xmlns="http://www.witsml.org/schemas/1series" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.4.1.1">
<log uidWell="uid1" uidWellbore="wb1" uid="wb1uid"><nameWell>well1</nameWell><nameWellbore>well1 - Main Wellbore</nameWellbore><name>12.25in. section - Time Log</name><serviceCompany>servicecompany1</serviceCompany><runNumber>1,2</runNumber><pass>Drilling</pass><creationDate>2008-09-07T11:58:27.000Z</creationDate><indexType>date time</indexType><startDateTimeIndex>2008-09-08T08:09:23.000Z</startDateTimeIndex><endDateTimeIndex>2008-09-08T21:21:41.000Z</endDateTimeIndex><direction>increasing</direction><indexCurve>TIME</indexCurve><priv_dTimPriority>2008-09-07T11:58:27.000Z</priv_dTimPriority>
<logCurveInfo uid="STIS"><mnemonic>STIS</mnemonic><unit>unitless</unit><minDateTimeIndex>1900-01-01T00:00:00.000Z</minDateTimeIndex><maxDateTimeIndex>1900-01-01T00:00:00.000Z</maxDateTimeIndex><curveDescription>Slips stat (1=Out,0=In)</curveDescription><dataSource>Drilling</dataSource><typeLogData>double</typeLogData>
</logCurveInfo>
<logCurveInfo uid="PDAZIMLO"><mnemonic>PDAZIMLO</mnemonic><unit>dega</unit><minDateTimeIndex>1900-01-01T00:00:00.000Z</minDateTimeIndex><maxDateTimeIndex>1900-01-01T00:00:00.000Z</maxDateTimeIndex><curveDescription>PowerDrive Azimuth Low Resolution</curveDescription><dataSource>PowerDrive</dataSource><typeLogData>double</typeLogData>
</logCurveInfo>
<logCurveInfo uid="DBTM"><mnemonic>DBTM</mnemonic><unit>m</unit><minDateTimeIndex>2008-09-08T08:09:23.000Z</minDateTimeIndex><maxDateTimeIndex>2008-09-08T21:21:41.000Z</maxDateTimeIndex><curveDescription>Bit Depth (MD)</curveDescription><dataSource>Drilling</dataSource><typeLogData>double</typeLogData>
</logCurveInfo>
<logCurveInfo uid="RPM"><mnemonic>RPM</mnemonic><unit>rpm</unit><minDateTimeIndex>1900-01-01T00:00:00.000Z</minDateTimeIndex><maxDateTimeIndex>1900-01-01T00:00:00.000Z</maxDateTimeIndex><curveDescription>Average Rotary Speed</curveDescription><dataSource>Drilling</dataSource><typeLogData>double</typeLogData>
</logCurveInfo>
<logData>
<mnemonicList>TIME,STIS,PDAZIMLO,DBTM</mnemonicList>
<unitList>s,unitless,dega,m</unitList>
<data>2008-09-08T08:09:23.000Z,,,137.7500001408</data>
<data>2008-09-08T08:09:32.000Z,,,137.7500001408</data>
<data>2008-09-08T08:09:36.000Z,,,137.7500001408</data>
<data>2008-09-08T08:09:41.000Z,,,137.7500001408</data>
<data>2008-09-08T08:09:45.000Z,,,137.7500001408</data>
</logData>
<commonData><sourceName>service_DS</sourceName><dTimCreation>2012-07-25T12:39:29.924Z</dTimCreation><dTimLastChange>2015-06-10T07:47:47.716Z</dTimLastChange><priv_userLastChange>scmanager</priv_userLastChange><priv_ipLastChange>143.97.229.4</priv_ipLastChange><priv_userOwner>f_sitecom_synchronizer@statoil.net</priv_userOwner><priv_ipOwner>192.168.157.1</priv_ipOwner><priv_dTimReceived>2015-06-10T07:47:47.716Z</priv_dTimReceived>
</commonData>
</log>
</logs>
我想创建一个 DataFrame,其中包含所有数据标记中的数据,并将 mnemonicList 标记中的内容作为列名。类似于下面的输出:
【问题讨论】:
-
“无法创建” - 你尝试了什么?
-
我确实通过以下步骤弄清楚并得到了我想要的东西:
标签: python pandas xml dataframe