"Поведение 'isin' с dtype=datetime64[ns] и приводимые значения (например, строки) устарели. В будущей версии они не будут считаться совпадающими с помощью isin. Вместо этого необходимо явно привести к соответствующему типу dtype."
Код: Выделить всё
import numpy as np
import pandas as pd
df = pd.DataFrame({'some_dates' :[pd.Timestamp('2024-09-30 00:00:00'),
pd.Timestamp('2024-09-23 00:00:00')]})
Код: Выделить всё
print(df.dtypes)
---output :
some_dates datetime64[ns]
dtype: object
Код: Выделить всё
df.query("some_dates in [('2024-09-30 00:00:00')]")
---output :
:1: FutureWarning: The behavior of 'isin' with dtype=datetime64[ns] and castable values (e.g. strings) is deprecated. In a future version, these will not be considered matching by isin. Explicitly cast to the appropriate dtype before calling isin instead.
df.query("some_dates in [('2024-09-30 00:00:00')]")
some_dates
0 2024-09-30
Код: Выделить всё
df['some_dates'].isin([np.datetime64('2024-09-30 00:00:00')])
---output :
some_dates
0 True
1 False
dtype: bool
Код: Выделить всё
df.query("some_dates in [np.datetime64('2024-09-30 00:00:00')]")
---output :
UndefinedVariableError: name 'np' is not defined
Код: Выделить всё
df.query("some_dates in [@pd.Timestamp('2024-09-30 00:00:00')]")
---output :
some_dates
0 2024-09-30
'''
Код: Выделить всё
df.query("some_dates in [@np.datetime64('2024-09-30 00:00:00')]")
---output :
TypeError: '>' not supported between instances of 'numpy._ArrayFunctionDispatcher' and 'int'
Подробнее здесь: https://stackoverflow.com/questions/790 ... ur-warning