-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Code Sample
This works fine:
In [16]: hours = pd.Series(pd.date_range('2017-01-01', '2017-01-31', freq='H'))
In [17]: hours.dt.ceil('D')
Out[17]:
0 2017-01-01
1 2017-01-02
2 2017-01-02
3 2017-01-02
4 2017-01-02
...
But this doesn't:
In [18]: days = pd.Series(pd.date_range('2017-01-01', '2017-01-31', freq='D'))
In [19]: days.dt.ceil('M')
...
/home/andrew/git/pandas-rosnfeld-py3/pandas/tseries/offsets.py in nanos(self)
510 @property
511 def nanos(self):
--> 512 raise ValueError("{0} is a non-fixed frequency".format(self))
513
514
ValueError: <MonthEnd> is a non-fixed frequency
Problem description
I haven't done an exhaustive test, but it seems that one can't use coarser frequencies like 'M', 'Q', 'A' in the dt.ceil/floor/round set of methods.
Expected Output
It would seem reasonable to be able to take a series of scattered dates and be able to "coarsen" them into month-ends, quarter-ends, year-ends, etc.
Output of pd.show_versions()
pandas: 0.19.0+300.g74e20a0.dirty
nose: 1.3.7
pip: 7.1.2
setuptools: 19.1.1
Cython: 0.23.4
numpy: 1.10.2
scipy: 0.16.1
statsmodels: None
xarray: None
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2016.4
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.6
feather: None
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.2
lxml: 3.5.0
bs4: None
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: 1.0.11
pymysql: 0.6.7.None
psycopg2: None
jinja2: 2.8
s3fs: None
pandas_datareader: None