gpt4 book ai didi

python - 如何设置从第三列绘制值的条件? python / Pandas

转载 作者:行者123 更新时间:2023-12-01 06:30:50 25 4
gpt4 key购买 nike

我已使用 pandas 将数据导入到 3 列中:DayOfYear、Field、Distance。

DayOfYear Field Distance
1 50 100
2 55 200
3 60 300
4 65 400
5 70 500
6 75 600
7 80 700
...

我想根据距离绘制场,但我想在我选择的一年中的任何日期范围内执行此操作。因此,不只是绘制所有 365 天的距离和场的所有值,我想将它们绘制为 226-346 天。我该怎么办?

最佳答案

使用Series.between表现 boolean indexingDataFrame.plot :

l1 = 226
l2 = 346
df[df['DayOfYear'].between(l1,l2)].set_index('Distance')['Field'].plot()

l1 = 2、l2 = 6 的示例

enter image description here

关于python - 如何设置从第三列绘制值的条件? python / Pandas ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59921152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com