大熊猫根据df中列出的文件名将多个csv文件导入大熊猫

时间:2020-07-30 09:15:35

标签: python-3.x pandas

我在数据框中有一个文件名列表

df['Forward']

[出局]:

6     305_F_SOL.CSV
8     309_F_SOL.CSV
12    312_F_SOL.CSV
13    325_F_SOL.CSV

我想在df ['Forward']中列出的文件上使用read_csv,并仅保留csv和append中的第25行。没关系,但是我不确定如何使其遍历df中的所有文件名。然后,应在每个文件名的新列中添加第25行的值。

这是我到目前为止所拥有的:

rows_to_keep = [25]

df1 = pd.read_csv(df['Forward'], sep=' , ', engine='python', header=None, index_col=None, skiprows = lambda x: x not in rows_to_keep)

这是我希望它看起来像的一个例子:

[Out]:
              Forward          Row 25 value
    6     305_F_SOL.CSV            14.6
    8     309_F_SOL.CSV            14.8
    12    312_F_SOL.CSV            17.2
    13    325_F_SOL.CSV            16.1

0 个答案:

没有答案