!pip install -U LeXmo
from LeXmo import LeXmo
df['Dict'] = df['Content '].apply(lambda x: [LeXmo.LeXmo(x)])
使用這個片段,我能夠生成這個

但我想要的輸出是

我想將 'Dict' 的每個字典鍵作為每一行的單獨列。我怎樣才能做到這一點??
uj5u.com熱心網友回復:
您可以將輸出從 轉換LeXmo.LeXmo(x)為Series,因此如果在 中呼叫函式,它會創建新列Series.apply,最后通過以下方式附加到原始 DataFrame DataFrame.join:
df = df.join(df['Content '].apply(lambda x: pd.Series(LeXmo.LeXmo(x))))
uj5u.com熱心網友回復:
你已經有字典了嗎?那么這個簡單的行應該做到這一點:
df = pandas.DataFrame.from_dict(myDict)
這里有一些更多資訊(如果你沒有使用你最喜歡的搜索引擎來解決這個問題)鏈接
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/479953.html
