-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Period converted to overflowing Timestamp in DataFrame.to_csv #15982
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
Labels
Dtype Conversions
Unexpected or buggy dtype conversions
IO CSV
read_csv, to_csv
IO Data
IO issues that don't fit into a more specific label
Period
Period data type
Milestone
Comments
This is only an issue when the period is in the index: In [5]: df.reset_index().to_csv("bug.csv", index=False)
In [6]: !cat bug.csv
index,0
1990-01-01,4
2000-01-01,5
3005-01-01,6 cc @gfyoung if you're interested in taking a look. |
This is what is called ultimately. Should be straightforward to fix.
|
@jreback : Right, but WAY before that, we call |
ahh ok, that that has to fallback to handle out-of-bounds timestamps. |
gfyoung
added a commit
to forking-repos/pandas
that referenced
this issue
Apr 12, 2017
gfyoung
added a commit
to forking-repos/pandas
that referenced
this issue
Apr 12, 2017
gfyoung
added a commit
to forking-repos/pandas
that referenced
this issue
Apr 12, 2017
gfyoung
added a commit
to forking-repos/pandas
that referenced
this issue
Apr 13, 2017
jreback
pushed a commit
that referenced
this issue
Apr 13, 2017
* BUG: Don't overflow PeriodIndex in to_csv Closes gh-15982. * TST: Test to_native_types for Period/DatetimeIndex
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Dtype Conversions
Unexpected or buggy dtype conversions
IO CSV
read_csv, to_csv
IO Data
IO issues that don't fit into a more specific label
Period
Period data type
Code Sample
Problem description
I have some data with dates in the far future (e.g. 4000-01-01). Following the documentation I am using
pandas.Period
: http://pandas.pydata.org/pandas-docs/stable/timeseries.html#representing-out-of-bounds-spansThis works, until I come to export the dataframe to a CSV (demonstrated in the code above). Printing the dataframe works as expected:
But the CSV files looks like this:
It looks like the
Period
has been converted to aTimestamp
and silently overflowed.Related to #13346, but I think worth a distinct issue.
Output of
pd.show_versions()
pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 33.1.0.post20170122
Cython: 0.25.2
numpy: 1.11.3
scipy: 0.18.1
statsmodels: 0.8.0
xarray: None
IPython: 5.3.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: 3.3.0
numexpr: 2.6.2
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.5
boto: 2.46.1
pandas_datareader: None
The text was updated successfully, but these errors were encountered: