Skip to content

BUG: first() and last() with DateOffset always give 1 row #51284

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

Closed
2 of 3 tasks
mvashishtha opened this issue Feb 10, 2023 · 2 comments
Closed
2 of 3 tasks

BUG: first() and last() with DateOffset always give 1 row #51284

mvashishtha opened this issue Feb 10, 2023 · 2 comments
Labels
Bug Frequency DateOffsets

Comments

@mvashishtha
Copy link

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
i = pd.date_range('2018-04-09', periods=4, freq='2D')
ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
# bug-- shows just 1 row
print(ts.first(pd.DateOffset(days=3)))
# shows 2 rows as in the docs: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.first.html
print(ts.first('3D'))

Issue Description

first() and last() take DateOffset, but passing a DateOffset always gives at most one row.

Expected Behavior

DateOffset(days=3) should work the same as '3D'.

Installed Versions

INSTALLED VERSIONS

commit : ca60aab
python : 3.10.4.final.0
python-bits : 64
OS : Darwin
OS-release : 21.5.0
Version : Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.4.4
numpy : 1.24.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 67.2.0
pip : 22.1.2
Cython : None
pytest : 7.2.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.7.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2023.1.0
gcsfs : None
markupsafe : 2.1.1
matplotlib : 3.6.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 8.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None

@mvashishtha mvashishtha added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 10, 2023
@DeaMariaLeon DeaMariaLeon added Frequency DateOffsets and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 31, 2023
@DeaMariaLeon
Copy link
Member

DeaMariaLeon commented Mar 31, 2023

take

@DeaMariaLeon
Copy link
Member

Thak you for the report @mvashishtha.
Unfortunately this function will be deprecated: #45908

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Frequency DateOffsets
Projects
None yet
Development

No branches or pull requests

2 participants