Open sam-s opened 4 days ago
I understand that the errors is caused by pd.DataFrame().index
being RangeIndex(start=0, stop=0, step=1)
but it seems reasonable that an empty frame should be filterable by any condition.
Barring that, how do I create an empty frame that can be filtered by Timestamp
?
do I really need to type
pd.DataFrame(index=pd.date_range(start=pd.Timestamp("2024-10-10"),freq="s", periods=0))
instead of
pd.DataFrame()
Thanks for the report. I think pandas should consider dtype compatibility even on empty objects. Otherwise you end up with cases where it appears that code works, but only because the objects are empty, and then will fail in cases where they are not empty.
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] 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
Issue Description
filtering an empty
DataFrame
by a non-numeric filter fails withExpected Behavior
an empty frame should be returned, just like with a numeric condition
Installed Versions