我想将我的列表转换为数据框。挑战在于我的列表中的项目如下所示,我需要将列表中每个项目的字符串值提取到数据框的列中。
列表看起来像
Keyword = [('Hello',2.0),('Welcome',3.0),('To',3.0),('Python',4.0)]
需要数据框作为
输出:
Keyword Score
0 Hello 2.0
1 Welcome 3.0
2 To 3.0
3 Python 4.0
有人可以提出一些解决方案吗。
请您参考如下方法:
使用 columns=["Keyword", "Score"]
例如:
import pandas as pd
Keyword = [ ('Hello',2.0),('Welcome',3.0),('To',3.0),('Python',4.0)]
df = pd.DataFrame(Keyword, columns=["Keyword", "Score"])
print(df)
输出:
Keyword Score
0 Hello 2.0
1 Welcome 3.0
2 To 3.0
3 Python 4.0
