0
import pandas as pd
sentences=['aaa','bbb','ccc']
labels = [1,2,3]
infos = zip(sentences , labels)
df_synthesize = pd.DataFrame(infos, columns = ['content','label'])
print(df_synthesize)
print(list(infos))

I use the infos to initialize the dataframe, however, after the creation, the infos becomes null list.

print(list(infos))

[]

It is quite weird, why this happens?

pandas version : 1.1.5

yanachen
  • 3,401
  • 8
  • 32
  • 64

1 Answers1

0

Try this. panddas: 1.1.5

import pandas as pd
sentences=['aaa','bbb','ccc']
labels = [1,2,3]
infos = list(zip(sentences , labels))
       // ^----------------------------------- clue
df_synthesize = pd.DataFrame(infos, columns = ['content','label'])
print(df_synthesize)

Output

  content  label
0     aaa      1
1     bbb      2
2     ccc      3
top talent
  • 615
  • 4
  • 17