Как сделать Pivot DataFrame без индекса в Python? - PullRequest
0 голосов
/ 31 октября 2019

У меня только 2 столбца. Например:

columns

Текущий код:

  def test_header(xml_file, df_cols):
    xtree = et.parse(xml_file)
    xroot = xtree.getroot()
    out_xml = pd.DataFrame(columns=df_cols)

    for node in xroot.findall(r'./ReportHeader/Section[1]/Subreport/Details/Section/Field'):
        name = node.attrib.get('Name')
        value=node.find('Value').text
        out_xml = out_xml.append(
            pd.Series([name,value], index=df_cols), ignore_index=True)
        df=out_xml.pivot(index='Authorize1', columns='name', values='value')

    csv = df.to_csv(r'ReportHeader.csv', index=None, header=True)

Однако мой результат получился как:

result

ТОГДА, я хочу, чтобы это было похоже на

wanted

Может ли кто-нибудь помочь?

...