输入:[["meas_date","point","val"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"]] 输出:数据透视表,index是meas_date列,columns是point列,值是val列 提供pandas代码,并输出结果
时间: 2023-08-10 14:09:57 浏览: 148
请使用以下的Python代码来生成数据透视表,并输出结果:
```python
import pandas as pd
data = [["meas_date","point","val"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5002","21.23"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5004","0.03"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5042","13.98"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5070","1.28"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5144","0"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5174","10.32"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5186","0"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","5289","11.4"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8063","0.01"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8157","0"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"],["2023-07-21","8192","-0.31"]]
# 将二维列表转换为DataFrame
df = pd.DataFrame(data[1:], columns=data[0])
# 进行数据透视
pivot_table = df.pivot(index="meas_date", columns="point", values="val")
# 输出结果
print(pivot_table)
```
运行以上代码,你将会得到一个数据透视表,其中 `meas_date` 列作为索引,`point` 列作为列名,`val` 列的值填充在相应的单元格中。
阅读全文