Skip to content

to_xml and read_xml #4734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #6
hayd opened this issue Sep 2, 2013 · 3 comments
Closed
Tracked by #6

to_xml and read_xml #4734

hayd opened this issue Sep 2, 2013 · 3 comments
Labels
Enhancement IO Data IO issues that don't fit into a more specific label IO HTML read_html, to_html, Styler.apply, Styler.applymap

Comments

@hayd
Copy link
Contributor

hayd commented Sep 2, 2013

http://stackoverflow.com/questions/18574108/how-do-convert-a-pandas-dataframe-to-xml
cc @jreback

I don't think there is a standard xml, but perhaps his could be generalised? If not maybe simply adding this recipe to the cookbook is useful.

Solutions for read_xml are hacking tree with from_records
http://stackoverflow.com/a/10948591/1240268
or just as a list http://stackoverflow.com/a/16993660/1240268

too much of a dark art to generalise?

@cpcloud
Copy link
Member

cpcloud commented Sep 2, 2013

could potentially base read_html on this

@cpcloud
Copy link
Member

cpcloud commented Sep 3, 2013

Could have elements like: value (values in a frame), column (column values), index (index values)

where a frame like

In [10]: df = DataFrame({'a':[1,2],'b':[3,4]})

In [11]: df.index.name = 'bob'; df.columns.name = 'jones'

In [12]: df
Out[12]:
jones  a  b
bob
0      1  3
1      2  4

results in the following XML

In [13]: print(df.to_xml())
<frame>
    <names>
      <axis value="0">bob</axis>
      <axis value="1">jones</axis>
    <names>
    <column name="a">
      <value index="0">1</value>
      <value index="1">2</value>
    </column>
    <column name="b">
      <value index="0">3</value>
      <value index="1">4</value>
    </column>
</frame>

For MultiIndex, axis elements could optionally take a level="the_level" attribute.

@jtratner
Copy link
Contributor

jtratner commented Sep 3, 2013

I feel like this is more useful for a specific case like 'convert this into
something that XYZ can read and happens to be xml' (which is basically what
the excel funcs do). Do we have a few concrete use case or cases to
discuss?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO Data IO issues that don't fit into a more specific label IO HTML read_html, to_html, Styler.apply, Styler.applymap
Projects
None yet
Development

No branches or pull requests

5 participants