Skip to content
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

BUG: Bug in to_json with certain orients and a CategoricalIndex would segfault, closes #10317 #10321

Closed
wants to merge 1 commit into from

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Jun 10, 2015

xref #10317

In [17]: df = DataFrame({ 'A' : pd.Series([3,2,2],index=pd.Categorical([1,2,3],categories=[1,2,3])), 'B' : pd.Categorical(list('aab')) })

In [18]: df
Out[18]: 
   A  B
1  3  a
2  2  a
3  2  b

In [19]: df.index
Out[19]: CategoricalIndex([1, 2, 3], categories=[1, 2, 3], ordered=False, dtype='category')

In [20]: df.dtypes
Out[20]: 
A       int64
B    category
dtype: object

In [31]: def f(orient):
    print "orient->%s" % orient
    print df.to_json(orient=orient)
   ....:     

In [32]: f('columns')
orient->columns
{"A":{"1":3,"2":2,"3":2},"B":{"1":"a","2":"a","3":"b"}}

In [33]: f('index')
orient->index
{"1":{"A":3,"B":"a"},"2":{"A":2,"B":"a"},"3":{"A":2,"B":"b"}}

In [34]: f('split')
orient->split
{"columns":["A","B"],"index":[1,2,3],"data":[[3,"a"],[2,"a"],[2,"b"]]}

In [35]: f('records')
orient->records
[{"A":3,"B":"a"},{"A":2,"B":"a"},{"A":2,"B":"b"}]

In [36]: f('values')
orient->values
[[3,"a"],[2,"a"],[2,"b"]]

@jreback jreback added Bug IO JSON read_json, to_json, json_normalize labels Jun 10, 2015
@jreback jreback added this to the 0.16.2 milestone Jun 10, 2015
@jreback jreback changed the title BUG: Bug in to_json with certain orients and a CategoricalIndex would segfault, closes #10307 BUG: Bug in to_json with certain orients and a CategoricalIndex would segfault, closes #10317 Jun 10, 2015
@jreback
Copy link
Contributor Author

jreback commented Jun 10, 2015

closing in favor of #10322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant