[Python] Import multiple data frames into repeat statements

Asked 2 years ago, Updated 2 years ago, 41 views

word_freqs = []

word_freqs.append(word_freqs_0)

word_freqs.append(word_freqs_1)

word_freqs.append(word_freqs_2)

word_freqs.append(word_freqs_3)

word_freqs.append(word_freqs_4)

word_freqs.append(word_freqs_5)

word_freqs.append(word_freqs_6)

word_freqs.append(word_freqs_7)

word_freqs.append(word_freqs_8)

I'd like to make the above source into a repeat statement. There are data frames from word_freeqs_0 to word_freeqs_8 and I want to append in word_freeqs What should I do?

python pandas

2022-09-20 11:30

1 Answers

for i in range(9):
    df = pd.DataFrame()
    word_freqs.append(df)

I think you can do it like this. If you're going to use a repetitive sentence, it seems better to use the variable name uniformly


2022-09-20 11:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.