Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

ctable.todataframe() does not save dataframe index values #344

Open
rytsim opened this issue Apr 30, 2017 · 1 comment
Open

ctable.todataframe() does not save dataframe index values #344

rytsim opened this issue Apr 30, 2017 · 1 comment

Comments

@rytsim
Copy link

rytsim commented Apr 30, 2017

Taking a pandas dataframe with a timedate index and converting it to ctable then converting it back to a dataframe the index values are lost.

df.head()
                       bid  offer
time                             
2017-04-28 05:10:35  154.0  154.5
2017-04-28 08:10:00  154.0    0.0
2017-04-28 08:10:00  154.0  155.5
2017-04-28 08:10:00  154.0  155.5
2017-04-28 08:15:06  154.5  155.5

Converting to a ctable and back.

ct = bcolz.ctable.fromdataframe(df)
df2 = ct.todataframe()

New dataframe does not have the index information.

df2.head()

     bid  offer
0  154.0  154.5
1  154.0    0.0
2  154.0  155.5
3  154.0  155.5
4  154.5  155.5

I could store the index values as a column, but it would make more sense to store the index values automatically.

@FrancescAlted
Copy link
Member

Yes, the index is a special column that is not represented in ctable containers, so roundtrips are currently not possible. Perhaps adding some special attribute to designate the index column in a ctable could be the way to support this. The attribute could be named something like: dataframe_index_column (or similar). Interested in sending a PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants