A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/13119 below:

resample with datetime64 data on series looses dtype · Issue #13119 · pandas-dev/pandas · GitHub

From SO: http://stackoverflow.com/questions/37106810/bug-in-python-pandas-pandas-series-resample-vs-pandas-dataframe-resample

In [7]: import datetime as dt

In [8]: df = pd.DataFrame([[dt.datetime(2016,1,31,15)], [dt.datetime(2016,2,7,17)]], index=[dt.datetime(2016,1,31,15), dt.datetime(2016,2,7,17)], columns=['timestamp'])

In [10]: df
Out[10]:
                              timestamp
2016-01-31 15:00:00 2016-01-31 15:00:00
2016-02-07 17:00:00 2016-02-07 17:00:00

In [11]: df.resample('D').first().timestamp
Out[11]:
2016-01-31   2016-01-31 15:00:00
2016-02-01                   NaT
2016-02-02                   NaT
2016-02-03                   NaT
2016-02-04                   NaT
2016-02-05                   NaT
2016-02-06                   NaT
2016-02-07   2016-02-07 17:00:00
Freq: D, Name: timestamp, dtype: datetime64[ns]

In [12]: df.timestamp.resample('D').first()
Out[12]:
2016-01-31    1.454252e+18
2016-02-01             NaN
2016-02-02             NaN
2016-02-03             NaN
2016-02-04             NaN
2016-02-05             NaN
2016-02-06             NaN
2016-02-07    1.454864e+18
Freq: D, Name: timestamp, dtype: float64

Tested it with latest master


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4