У меня большой список текстов песен. Каждый элемент в списке является песней, и каждая песня имеет несколько строк, и некоторые из этих строк являются заголовками, такими как «[Intro]», «[Chorus]» и т. Д. c. Я пытаюсь перебрать список и создать новые списки, где каждый новый список состоит из всех строк в определенном разделе, например «[Intro]» или «[Chorus]». Как только я достигну этого, я хочу создать фрейм данных Pandas, в котором каждая строка - это все тексты песен, а каждый столбец - это раздел (вступление, припев, стих 1 и т. Д. c.) Песни. Думаю ли я об этом правильный путь? Вот пример 1 элемента в списке и моей текущей частичной попытки выполнить итерацию и сохранить:
song_index_number = 0
line_index_in_song = 0
intro = []
bridge = []
verse1 = []
prechorus = []
chorus = []
verse2 = []
verse3 = []
verse4 = []
verse5 = []
outro = []
lyrics_by_song[30]
['[Intro]',
'(Just the two of us, just the two of us)',
'Baby, your dada loves you',
"And I'ma always be here for you",
'(Just the two of us, just the two of us)',
'No matter what happens',
"You're all I got in this world",
'(Just the two of us, just the two of us)',
"I would never give you up for nothin'",
'(Just the two of us, just the two of us)',
'Nobody in this world is ever gonna keep you from me',
'I love you',
'',
'[Verse 1]',
"C'mon Hai-Hai, we goin' to the beach",
'Grab a couple of toys and let Dada strap you in the car seat',
"Oh, where's Mama? She's takin' a little nap in the trunk",
"Oh, that smell? Dada must've runned over a skunk",
"Now, I know what you're thinkin', it's kind of late to go swimmin'",
"But you know your Mama, she's one of those type of women",
"That do crazy things, and if she don't get her way, she'll throw a fit",
"Don't play with Dada's toy knife, honey, let go of it (No)",
"And don't look so upset, why you actin' bashful?",
"Don't you wanna help Dada build a sandcastle? (Yeah)",
'And Mama said she wants to show you how far she can float',
"And don't worry about that little boo-boo on her throat",
"It's just a little scratch, it don't hurt",
"Her was eatin' dinner while you were sweepin'",
'And spilled ketchup on her shirt',
"Mama's messy, ain't she? We'll let her wash off in the water",
"And me and you can play by ourselves, can't we?",
'',
'[Chorus]',
'Just the two of us, just the two of us',....
for line in lyrics_by_song:
if lyrics_by_song == '[Intro]':
intro.append(line)