python
1import pandas as pd
2import numpy as np
3
4pd.set_option('display.unicode.east_asian_width', True)
5
6# generate dataframe for testing
7N = 729
8df4 = pd.DataFrame({
9 'Date': pd.date_range(start='2016/4/1', periods=N).strftime('%Y/%-m/%-d'),
10 'A': np.random.randint(1, 100, N),
11 'B': np.random.randint(0, 10, N),
12 '温度': np.random.rand(N)*30,
13 '祝日': np.random.randint(0, 2, N),
14})
15
16#
17df4['Serial value'] = (pd.to_datetime(df4['Date'])-pd.Timestamp('1899-12-30')).dt.days
18print(df4)
19
20#
21 Date A B 温度 祝日 Serial value
220 2016/4/1 8 9 4.488677 0 42461
231 2016/4/2 92 5 17.910199 0 42462
242 2016/4/3 39 2 3.273288 1 42463
253 2016/4/4 88 6 23.380190 1 42464
264 2016/4/5 34 7 26.968218 1 42465
27.. ... .. .. ... ... ...
28724 2018/3/26 34 9 10.059712 1 43185
29725 2018/3/27 52 0 25.889943 0 43186
30726 2018/3/28 49 1 24.548080 0 43187
31727 2018/3/29 45 1 22.938820 0 43188
32728 2018/3/30 59 6 7.381701 0 43189
33
34[729 rows x 6 columns]
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。