要组合dates和true_predictions来创建一个DataFrame,可以使用pandas库中的DataFrame函数。首先,导入pandas库:
import pandas as pd
然后,将dates和true_predictions作为字典的键值对传递给DataFrame函数,其中dates作为"dates"列,true_predictions作为"true_predictions"列。示例代码如下:
dates = ['2022-01-01', '2022-01-02', '2022-01-03']
true_predictions = [10, 15, 20]
df = pd.DataFrame({'dates': dates, 'true_predictions': true_predictions})
这样就创建了一个名为df的DataFrame,其中包含两列:"dates"和"true_predictions"。可以通过打印df来查看DataFrame的内容:
print(df)
输出结果如下:
dates true_predictions
0 2022-01-01 10
1 2022-01-02 15
2 2022-01-03 20
这样就成功地将dates和true_predictions组合成了一个DataFrame。
云+社区技术沙龙[第15期]
Elastic 实战工作坊
Elastic 实战工作坊
云+社区沙龙online第6期[开源之道]
云+社区技术沙龙[第27期]
云原生正发声
云+社区开发者大会 长沙站
云+社区沙龙online
Elastic 实战工作坊
领取专属 10元无门槛券
手把手带您无忧上云