根据列值创建列表

时间:2019-02-20 16:27:01

标签: python pandas

我有以下df,我试图根据“ combined_sector”列中的值创建一个逗号分隔的列表。结果应如下所示:

IG信用:金融-雷曼兄弟部门:'46647PAY2','36164QMS4','36164QMS4'

高收益:工业-雷曼兄弟部门:'26112TAJ5','29273VAD2'

    cusip   sector_path_0   sector_path_1   sector_path_2   combined_sector
0   46647PAY2   FMBI UNIV Breakdown IG Credit   Financials - Lehman Sector  IG Credit: Financials - Lehman Sector
1   36164QMS4   FMBI UNIV Breakdown IG Credit   Financials - Lehman Sector  IG Credit: Financials - Lehman Sector
2   948741AH6   FMBI UNIV Breakdown IG Credit   Financials - Lehman Sector  IG Credit: Financials - Lehman Sector
3   26112TAJ5   FMBI UNIV Breakdown High Yield  Industrials - Lehman Sector High Yield: Industrials - Lehman Sector
4   29273VAD2   FMBI UNIV Breakdown High Yield  Industrials - Lehman Sector High Yield: Industrials - Lehman Sector

是否可以选择在哪些列上使用df['column'].values.tolist()?意思是,我可以选择从哪些列创建列表吗?

0 个答案:

没有答案