回答編集履歴

1

2023/01/27 15:49

投稿

melian
melian

スコア19703

test CHANGED
@@ -2,7 +2,7 @@
2
2
  import pandas as pd
3
3
 
4
4
  df = pd.read_csv('csvのパス', parse_dates=['DateTime'])
5
- df['diff'] = df['DateTime'].diff().astype('timedelta64[s]')
5
+ df['diff'] = df['DateTime'].diff().dt.total_seconds()
6
6
  df['flg'] = df['diff'].where(df['diff'].isna(), df['diff'].le(30) * 1)
7
7
  df.to_csv('output.csv', index=False)
8
8
  ```