pd.pivot_table
# df
valueUpdateTime factorName value
0 2023-03-28 08:00:18.532805 风向 147.69
1 2023-03-28 08:00:18.532805 气压 101.71
2 2023-03-28 08:00:18.532805 风速 0.28
3 2023-03-28 08:00:18.532805 温度 18.55
4 2023-03-28 08:00:18.532805 湿度 91.76
... ... ...
1057 2023-03-28 08:29:59.201065 风速 0.96
1058 2023-03-28 08:29:59.201065 气压 101.74
1059 2023-03-28 08:29:59.201065 风向 139.06
1060 2023-03-28 08:29:59.201065 湿度 91.27
1061 2023-03-28 08:29:59.201065 温度 18.76
# df2
df2 = pd.pivot_table(df, index=['valueUpdateTime'], columns=['factorName'], value='value')
factorName TVOC 气压 温度 湿度 风向 风速
valueUpdateTime
2023-03-28 08:00:18.532805 9.59 101.71 18.55 91.76 147.69 0.28
2023-03-28 08:00:19.527816 9.59 101.71 18.53 91.76 110.31 0.88
2023-03-28 08:00:29.256678 9.59 101.71 18.53 91.79 93.97 0.77
2023-03-28 08:00:39.290946 9.59 101.71 18.59 91.76 0.00 0.00
2023-03-28 08:00:49.247142 9.59 101.71 18.56 91.76 248.48 0.46
... ... ... ... ... ...
2023-03-28 08:29:19.192815 9.63 101.73 18.80 91.36 156.58 1.03
2023-03-28 08:29:29.192907 9.63 101.73 18.77 91.35 149.69 1.14
2023-03-28 08:29:39.192674 9.63 101.73 18.77 91.28 10.41 0.59
2023-03-28 08:29:49.219851 9.63 101.74 18.79 91.26 73.64 0.23
2023-03-28 08:29:59.201065 9.63 101.74 18.76 91.27 139.06 0.96
标签:index,00,某列,03,Python,08,28,29,2023
From: https://www.cnblogs.com/jessecheng/p/17317960.html