-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
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
index = pd.DatetimeIndex(['2022-01-01 00:00:00', 'NaT',
'2022-01-01 00:00:01', '2022-01-01 00:00:02',
'2022-01-01 00:00:03', '2022-01-01 01:00:01',
'2022-01-01 02:00:02', '2022-01-01 03:00:03',
'2032-01-01 01:00:01', '2042-01-01 01:00:01',
'2032-01-01 01:00:01', '2052-01-01 01:00:01',
'2100-12-31 11:59:59'],
dtype='datetime64[ns]', name='TIME', freq=None)
df = pd.DataFrame(index=index, data=list(range(13)))
# this correctly prints just the first row
print(df.first('1s'))
# this incorrectly also prints just the first row
print(df.first('2s'))
# this correctly prints 4 rows from the first 3 seconds, including 0
print(df.first('3s'))Issue Description
first('1s') correctly prints just the first row, but first('2s') also only prints the first row.
Expected Behavior
first('2s') should gives rows 1 and 3 (indexing from 1) and exclude the null.
Installed Versions
/Users/maheshvashishtha/opt/anaconda3/envs/pandas-dev-alt/lib/python3.8/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
INSTALLED VERSIONS
commit : 2e218d1
python : 3.8.16.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.5.3
numpy : 1.24.1
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 65.6.3
pip : 22.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None