-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Snap drops name from datetimeindex #25575
Comments
Thanks for the report. There's actually a comment in the code that notes that this is missing (as well as tz). PR's welcome! pandas/pandas/core/indexes/datetimes.py Lines 790 to 791 in 3e652ac
|
How does snap actually work? pd.date_range(start='2019-1-1', end='2019-1-2', freq='10T').snap('H') Doesn't return what I expect. Is this a bigger bug? |
…ndas-dev#25575. Signed-off-by: HE, Tao <[email protected]>
I'm not exactly sure how snap is supposed to work or what differentiates it from round. Don't think I've seen a single working example showing how snap is intended to be used. Does anyone know what it's supposed to do beyond the one sentence description in the docstring? |
I have been poking around through trial and error. The best that I can come up with is that:
I came across |
Code Sample, a copy-pastable example if possible
Problem description
The DatetimeIndex.snap method loses the name of the DatetimeIndex which is a different behaviour than DatetimeIndex.round (or floor, ceil, etc.) that preserves the name of the DatetimeIndex.
Expected Output
DatetimeIndex([], dtype='datetime64[ns]', name='my_dti', freq='D')
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-45-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: en_CA.UTF-8
pandas: 0.24.1
pytest: 4.0.0
pip: 19.0.3
setuptools: 40.4.3
Cython: 0.29.6
numpy: 1.16.2
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.3.0
sphinx: None
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: 4.2.1
bs4: None
html5lib: 1.0.1
sqlalchemy: 1.2.18
pymysql: None
psycopg2: 2.7.7 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: 0.9.0
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: