【问题标题】:Not able to create a DataFrame from the WITSML file无法从 WITSML 文件创建 DataFrame
【发布时间】: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


【解决方案1】:

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 2021-08-19
  • 2021-12-08
  • 1970-01-01
  • 2018-02-13
  • 2011-10-28
  • 2018-11-07
  • 2012-08-28
  • 2019-12-22
相关资源
最近更新 更多