【发布时间】:2021-09-27 09:08:12
【问题描述】:
如何使用 for 循环根据其索引绘制列表中的数据?
(我需要写点东西,因为我的帖子主要是代码,我还有点添加更多细节......)
这是代码示例:
import pandas as pd
import os
import matplotlib.pyplot as plt
import numpy as np
path = r'D:\Experiments\20210924_SureliteOPO_beampointing\all_log'
filesnames = os.listdir(path)
filesnames = [f for f in filesnames if (f.startswith("2") and f.lower().endswith(".csv"))]
dfs = list() # a list of dataframes
for csvfile in filesnames:
fpath = path + '/' + csvfile
df = pd.read_csv(fpath, skiprows=26, skipfooter=5)
dfs.append(df)
print(dfs)
输出如下:
[ Powermeter1 Start
0 0.001864
1 0.001756
2 0.001818
3 0.001837
4 0.001932
.. ...
95 0.001697
96 0.001950
97 0.001871
98 0.001757
99 0.001849
[100 rows x 1 columns], Powermeter1 Start
0 0.001771
1 0.001863
2 0.001796
3 0.001885
4 0.001746
.. ...
95 0.001827
96 0.001678
97 0.001813
98 0.001776
99 0.001637
[100 rows x 1 columns]], ...
...
...
问候,
卡尔
【问题讨论】: