Python 有没有办法从所有30个数据帧中只提取一列?

Python 有没有办法从所有30个数据帧中只提取一列?,python,pandas,Python,Pandas,我有30个数据帧,但是从每个数据帧中我只需要一列。每个数据框都包含股票价格OHLC、Adj Close和交易量。我只想从30个数据帧中提取一列,即“Adj Close” 如何做到这一点而不使代码冗长?使用列表理解: dfs = [df1, df2, df3...df30] #if need Series out = [df['Adj Close'] for df in dfs] #if need one column DataFrames #out = [df[['Adj Close']] f

我有30个数据帧,但是从每个数据帧中我只需要一列。每个数据框都包含股票价格OHLC、Adj Close和交易量。我只想从30个数据帧中提取一列,即“Adj Close”


如何做到这一点而不使代码冗长?

使用列表理解:

dfs = [df1, df2, df3...df30]

#if need Series
out = [df['Adj Close'] for df in dfs]
#if need one column DataFrames
#out = [df[['Adj Close']] for df in dfs]
或循环:

out = []
for df in dfs:
    #if need Series
    out.append(df['Adj Close']) 
    #if need one column DataFrames
    out.append(df[['Adj Close']]) 
最后,如果每个系列的每个列需要一个大数据帧:

df_big = pd.concat(out, ignore_index=True, axis=1)

此命令实际上是将所有关闭值追加到另一个值之下。我们如何在一个新的数据框中关闭单独的Adj列?@the_learning_child-你认为
df\u big=pd.concat(out,ignore\u index=True,axis=1)
?是的,我忘记了
axis=1
现在它给出了正确的输出。非常感谢。