我有一个包含一列和多行的数据框。每行包含一首歌曲的歌词,行由“\n”分隔,到目前为止我所拥有的是
with open('Lyrics_Pavement.json') as json_data:
data = json.load(json_data)
df = pd.DataFrame(data['songs'])
df1 = df.lyrics.str.split(pat="\n")
然后 df1 包含一个 1 列数据帧,其中歌词已被删除并被“[]”包围。
1 [It's the shouting, it's the shouting, It's the Dutchman, it's the Dutchman shout, Get it away, I don't need your shaft, It's the shouting, it's the shouting, It's the shouting, it's the Dutchman shout, Give it away, I don't need your shaft, (yes I do), It's the shouting, it's the shouting, It's the shouting, it's the Dutchman shout, Get it away, I don't need your shaft]
这是第 1 行的示例。我如何让数据显示为这样:
It's the shouting,
It's the shouting,
It's the dutchman
等等。上面的每一新行都是数据帧的一行。然后对于第 2 行,将相同的歌词附加到该数据帧。
谢谢!
GCT1015
森林海
繁星淼淼
相关分类