Skip to content

Pandas DataFrame.to_json() does a Segmentation fault with data datetime64[ns, TimeZone] #11820

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
shishirsharma opened this issue Dec 11, 2015 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request IO JSON read_json, to_json, json_normalize Timezones Timezone data dtype

Comments

@shishirsharma
Copy link

This is the working example

(env)vagrant@app01:~/repos/peppertap_v1/shopper_bot$ uname -a
Linux app01 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
(env)vagrant@app01:~/repos/peppertap_v1/shopper_bot$ python --version
Python 2.7.6
(env)vagrant@app01:~/repos/peppertap_v1/shopper_bot$ pip list | grep num
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
numpy (1.10.1)
phonenumbers (6.0.0a0)
(env)vagrant@app01:~/repos/peppertap_v1/shopper_bot$ pip list | grep pandas
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pandas (0.17.1)
env)vagrant@app01:~/repos/peppertap_v1/shopper_bot$ python 
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> df = pd.DataFrame({'A' : pd.date_range('20130101',periods=3), 'B' : pd.date_range('20130101',periods=3,tz='US/Eastern'), 'C' : pd.date_range('20130101',periods=3,tz='CET')})
>>> df.dtypes
A                datetime64[ns]
B    datetime64[ns, US/Eastern]
C           datetime64[ns, CET]
dtype: object
>>> df.to_json()
Segmentation fault (core dumped)
(env)vagrant@app01:~/repos/peppertap_v1/shopper_bot$ 

The only solution I found is to remove tz_localize(None)

(env)vagrant@app01:~/repos/peppertap_v1/shopper_bot$ python 
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> df = pd.DataFrame({'A' : pd.date_range('20130101',periods=3), 'B' : pd.date_range('20130101',periods=3), 'C' : pd.date_range('20130101',periods=3)})
>>> df.to_json()
'{"A":{"0":1356998400000,"1":1357084800000,"2":1357171200000},"B":{"0":1356998400000,"1":1357084800000,"2":1357171200000},"C":{"0":1356998400000,"1":1357084800000,"2":1357171200000}}'
>>> 
(env)vagrant@app01:~/repos/peppertap_v1/shopper_bot$ 
@jreback
Copy link
Contributor

jreback commented Dec 11, 2015

dupe of #11473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request IO JSON read_json, to_json, json_normalize Timezones Timezone data dtype
Projects
None yet
Development

No branches or pull requests

2 participants