📌  相关文章
📜  python提取列中具有不同值的值 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:17.843000             🧑  作者: Mango

代码示例2
df = pd.DataFrame({'author':['a', 'a', 'b'], 'products':['sr1', 'sr2', 'sr2']}) # Create df

group = df.groupby('author') # Group by author used as index
df2 = group.apply(lambda x: x['subreddit'].unique()) # List of all product per author
df2 = df2.apply(pd.Series) # Split products in multiple columns