python
1df.info() 2<class 'pandas.core.frame.DataFrame'> 3RangeIndex: 367 entries, 0 to 366 4Data columns (total 6 columns): 5 # Column Non-Null Count Dtype 6--- ------ -------------- ----- 7 0 date 365 non-null object 8 1 7 367 non-null float64 9 2 8 367 non-null float64 10 3 9 367 non-null float64 11 4 10 367 non-null float64 12 5 11 205 non-null float64 13dtypes: float64(5), object(1) 14memory usage: 17.3+ KB
python
1df.head() 2 3date 7 8 9 10 11 40 9/1 15.0 9.0 17.0 13.0 11.0 51 9/2 14.0 12.0 7.0 10.0 9.0 62 9/3 10.0 13.0 16.0 9.0 7.0 73 9/4 12.0 6.0 12.0 5.0 10.0 84 9/5 11.0 14.0 14.0 10.0 9.0
このようなデータをto_datetimeを使って、日付型にしたときに、
pyrhon
1df['date'] = pd.to_datetime(df['date'], format = '%m/%d') 2df 3 date 7 8 9 10 11 40 1900-09-01 15.0 9.0 17.0 13.0 11.0 51 1900-09-02 14.0 12.0 7.0 10.0 9.0 62 1900-09-03 10.0 13.0 16.0 9.0 7.0 73 1900-09-04 12.0 6.0 12.0 5.0 10.0 84 1900-09-05 11.0 14.0 14.0 10.0 9.0 9... ... ... ... ... ... ... 10360 1900-08-27 9.0 13.0 15.0 15.0 NaN 11361 1900-08-28 11.0 13.0 11.0 12.0 NaN 12362 1900-08-29 8.0 13.0 10.0 5.0 NaN 13363 1900-08-30 8.0 11.0 11.0 8.0 NaN 14364 1900-08-31 5.0 15.0 10.0 11.0 NaN
このように1900ーが勝手についてしまいます。1900を付けずに、月と日だけにすることは可能でしょうか。
あなたの回答
tips
プレビュー