且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

遍历csv列以创建多个python数据框

更新时间:2023-12-01 13:29:22

这符合您的要求:

all_dfs = []
for col in df.columns:
    if col != 'Date':
        df_current = df[['Date', col]]
        all_dfs.append(df_current)

或一行:

all_dfs = [df[['Date', col]] for col in df.columns if col != 'Date']

但是您可能不想这样做.没有什么意义.你到底想做什么?

But you probably don't want to do that. There's not much point. What are you really trying to do?