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
(Pdb) pd.Timestamp(df['Time'])
*** TypeError: Cannot convert input [0 2017-11-21 09:37:12.553700-05:00
1 2017-11-21 10:25:48.511700-05:00
2 2017-11-21 10:25:48.511700-05:00
3 2017-11-21 10:31:42.510400-05:00
4 2017-11-21 11:56:54.469700-05:00
...
12248779 2022-10-28 19:01:50.953486-04:00
12248780 2022-10-28 19:01:50.953486-04:00
12248781 2022-10-28 19:01:50.953486-04:00
12248782 2022-10-28 19:03:17.621808-04:00
12248783 2022-10-28 19:39:54.522840-04:00
Name: Time, Length: 12248784, dtype: datetime64[ns, America/New_York]] of type <class 'pandas.core.series.Series'> to Timestamp
(Pdb) df['Time'].dtype
datetime64[ns, America/New_York]
(Pdb) window_end = df['Time'].max()
(Pdb) window_start = window_end - pd.Timedelta(30, 'days')
(Pdb) df['Time'] > window_start & df['Time'] <= window_end
*** TypeError: unsupported operand type(s) for &: 'Timestamp' and 'DatetimeArray'
Issue Description
When computing a mask between datetime64 objects and a Timestamp, converting the datetime64 to timestamp fails without providing context as to why it fails.
Expected Behavior
It should return a masked dataframe
Installed Versions
Pandas: Latest Python: Latest
Comment From: MarcoGorelli
Hi @jbcurtin, thanks for the report
This isn't a reproducible example - for a start, what's df
?
You probably want
(df['Time'] > window_start) & (df['Time'] <= window_end)
Closing for now, but will reopen if you include a reproducible example