1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

TypeError: Invalid comparison between dtype=datetime64[ns, UTC] and datetime

Last updated at Posted at 2023-01-29

TypeError: Invalid comparison between dtype=datetime64[ns, UTC] and datetime

  • 片方にタイムゾーンがあり、もう片方にタイムゾーンがない場合は比較できない
  • データ形式を合わせる必要がある

DataFrame

          price   size                 timestamp
0      23000.50  0.001 2023-01-28 21:58:48+00:00
1      23000.00  0.008 2023-01-28 21:58:51+00:00
2      23000.00  0.001 2023-01-28 21:58:51+00:00
3      22999.50  0.001 2023-01-28 21:58:51+00:00
4      22999.50  0.016 2023-01-28 21:58:51+00:00

x

df = df[df['timestamp'] > dt.datetime(2023,1,29)]

time = pd.Timestamp('2023-01-29 00:00:00+00:00')
df = df[df['timestamp'] > time]

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?