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

ValueError: Data type datetime64[ns] not currently understood. Please report an error to the developers. #12259

Closed
randomgambit opened this issue Feb 8, 2016 · 4 comments
Labels
Error Reporting Incorrect or improved errors from pandas IO Stata read_stata, to_stata

Comments

@randomgambit
Copy link

I do what I am told to do ;-)

I have a big dataframe with the following columns

daily_news.dtypes
Out[11]: 
stock_ric                       object
obs_day                 datetime64[ns]
next_dayfirst           datetime64[ns]
sentimentmean                  float32
sentimentcount                   int64
companyNamefirst                object
timestamp_localfirst    datetime64[ns]
tickerfirst                     object
text                      object
dtype: object

and I try to save it using pd.to_stata

daily_news.to_stata( "mypath/data.dta",convert_dates= {'obs_day' : 'td'})

and I get

daily_news.to_stata( "python_news.dta",convert_dates= {'obs_day' : 'td'})
Traceback (most recent call last):

  File "<ipython-input-9-3d9426807f61>", line 1, in <module>
    daily_news.to_stata( "python_news.dta",convert_dates= {'obs_day' : 'td'})

  File "C:\Users\m1hxb02\AppData\Local\Continuum\Anaconda2\lib\site-packages\pandas\core\frame.py", line 1456, in to_stata
    write_index=write_index)

  File "C:\Users\m1hxb02\AppData\Local\Continuum\Anaconda2\lib\site-packages\pandas\io\stata.py", line 1859, in __init__
    self._prepare_pandas(data)

  File "C:\Users\m1hxb02\AppData\Local\Continuum\Anaconda2\lib\site-packages\pandas\io\stata.py", line 2043, in _prepare_pandas
    self.fmtlist.append(_dtype_to_default_stata_fmt(dtype, data[col]))

  File "C:\Users\m1hxb02\AppData\Local\Continuum\Anaconda2\lib\site-packages\pandas\io\stata.py", line 1802, in _dtype_to_default_stata_fmt
    "Please report an error to the developers." % dtype)

ValueError: Data type datetime64[ns] not currently understood. Please report an error to the developers.
@jreback
Copy link
Contributor

jreback commented Feb 8, 2016

pls pd.show_versions() and provide a reproducible example.

IIRC this is simply not supported

cc @kshedden this should be NotImplementedError in this case

@jreback jreback added Error Reporting Incorrect or improved errors from pandas IO Stata read_stata, to_stata labels Feb 8, 2016
@randomgambit
Copy link
Author

pd.show_versions()


INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_US

pandas: 0.17.1
nose: 1.3.7
pip: 7.1.2
setuptools: 18.5
Cython: 0.23.4
numpy: 1.10.1
scipy: 0.16.0
statsmodels: None
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.4.4
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.9
pymysql: None
psycopg2: None
Jinja2: None

I ll try to get a working example.
what do you mean by IIRC this is simply not supported?

thanks!

@kshedden
Copy link
Contributor

kshedden commented Feb 8, 2016

Try converting the datetime64 to an array of datetimes, some examples here:

http://stackoverflow.com/questions/13703720/converting-between-datetime-timestamp-and-datetime64

@bashtage
Copy link
Contributor

This error is happening because the call to_stata is being used on a DF that has datetimes but these have not been included in the convert_dates dict. If you included keys for all datetime columns, this command should work as expected.

Will try a PR that will default to tc type which is close to datetime64, only using ms rather than ns.

bashtage added a commit to bashtage/pandas that referenced this issue Jul 20, 2016
Automatically select type %tc for datetime[ns] columns
Change ValueErrors to NotImplementedError for unsupported types
Add tests for select exceptions
Improve to_stata and StataWriter docstrings

closes pandas-dev#12259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas IO Stata read_stata, to_stata
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants