Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Empty data frames not round-trippable to JSON #21287
import pandas as pd df = pd.DataFrame(, columns=['a', 'b', 'c']) df.to_json('tmp.json', orient='table') pd.read_json('tmp.json', orient='table') >> KeyError: "['index' 'a' 'b' 'c'] not in index"
Empty data frames saved as JSON fail to load back to data frames.
df = DataFrame(table['data'], columns=col_order)[col_order]
print(df) Empty DataFrame Columns: [a, b, c] Index: 
pushed a commit
Jun 4, 2018
referenced this issue
Jun 4, 2018
On Fri, Jun 1, 2018 at 3:04 PM William Ayd ***@***.***> wrote: Thanks for the report and investigation - care to make a PR? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#21287 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABzdrLAH5ySqQHG4OiMsoRLRsNxxl5XJks5t4ZA8gaJpZM4UXHVI> .
I actually ended up diving into this with my PR #21318. I did the changes the way @ludaavics initially suggested (BTW, thanks for heads-up with the example!). After writing a unit test for it I realised that now that the actual error is fixed the DF read back from the JSON gets a different index type than it originally had:
Need to dig this a bit deeper now. Any initial thoughts on why this might happen or am I missing something?
(This is my first contribution for this project, so might be something obvious that I have not (yet) noticed)