We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
import pandas as pd dt = {'No': {pd.Timestamp('2020-01-01 00:00:00'): 123, pd.Timestamp('1900-01-01 00:00:00'): 345, pd.Timestamp('2017-04-18 00:00:00'): 946, pd.Timestamp('2020-01-02 00:00:00'): 940 }, 'CB': {pd.Timestamp('2020-01-01 00:00:00'): 'Sc', pd.Timestamp('1900-01-01 00:00:00'): 'Dr', pd.Timestamp('2017-04-18 00:00:00'): 'St', pd.Timestamp('2020-01-02 00:00:00'): 'Sc'}} df = pd.DataFrame(dt) # **only January 1 does not work properly** print(df['2019-12-31':]) print(df['2020-01-01':]) print(df['2020-01-02':]) # **All work properly** print(df[df.index >='2019-12-31']) print(df[df.index >='2020-01-01']) print(df[df.index >='2020-01-02'])
Slicing by datetime index on January 1, 2020 returns the whole DataFrame
print(df['2020-01-01':])
Shows the whole DataFrame
incorrectly shows the whole DataFrame
No CB
2020-01-01 123 Sc 1900-01-01 345 Dr 2017-04-18 946 St 2020-01-02 946 Sc
print(df['2020-01-02':])
No CB 2020-01-02 946 Sc
print(df[df.index >='2019-12-31'])
No CB 2020-01-01 123 Sc 2020-01-02 946 Sc
print(df[df.index >='2020-01-01'])
#works properly No CB 2020-01-01 123 Sc 2020-01-02 946 Sc
print(df[df.index >='2020-01-02'])
2020-01-01 123 Sc 2020-01-02 946 Sc
pd.show_versions()
commit : None python : 3.7.2.final.0 python-bits : 32 OS : Windows OS-release : 10 machine : AMD64 processor : Intel64 Family 6 Model 142 Stepping 9, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : None.None
pandas : 1.0.3 numpy : 1.18.2 pytz : 2018.9 dateutil : 2.8.0 pip : 20.0.2 setuptools : 40.6.2 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 2.10 IPython : 7.4.0 pandas_datareader: None bs4 : None bottleneck : None fastparquet : None gcsfs : None lxml.etree : None matplotlib : 3.0.3 numexpr : None odfpy : None openpyxl : 3.0.2 pandas_gbq : None pyarrow : None pytables : None pytest : None pyxlsb : None s3fs : None scipy : 1.2.1 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : 1.2.0 xlwt : None xlsxwriter : None numba : None
The text was updated successfully, but these errors were encountered:
it's working fine .
2020-01-01 123 Sc 2020-01-02 940 Sc
Sorry, something went wrong.
I'm seeing an exception raised when slicing df["2019-12-31":] and the others working as expected. df.loc["2019-12-31":] works as expected
df["2019-12-31":]
df.loc["2019-12-31":]
Edit: Exception is no longer raised, but
still returns
No CB 2020-01-01 123 Sc 1900-01-01 345 Dr 2017-04-18 946 St 2020-01-02 940 Sc
Successfully merging a pull request may close this issue.
Code Sample, a copy-pastable example if possible
Problem description
Slicing by datetime index on January 1, 2020 returns the whole DataFrame
print(df['2020-01-01':])
Shows the whole DataFrame
Expected Output
only January 1 does not work properly
print(df['2020-01-01':])
incorrectly shows the whole DataFrame
2020-01-01 123 Sc
1900-01-01 345 Dr
2017-04-18 946 St
2020-01-02 946 Sc
print(df['2020-01-02':])
No CB
2020-01-02 946 Sc
All work properly
print(df[df.index >='2019-12-31'])
No CB
2020-01-01 123 Sc
2020-01-02 946 Sc
print(df[df.index >='2020-01-01'])
#works properly
No CB
2020-01-01 123 Sc
2020-01-02 946 Sc
print(df[df.index >='2020-01-02'])
2020-01-01 123 Sc
2020-01-02 946 Sc
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit : None
python : 3.7.2.final.0
python-bits : 32
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.0.3
numpy : 1.18.2
pytz : 2018.9
dateutil : 2.8.0
pip : 20.0.2
setuptools : 40.6.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 7.4.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.0.3
numexpr : None
odfpy : None
openpyxl : 3.0.2
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.2.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : None
The text was updated successfully, but these errors were encountered: