Python List -> How to Create Data Frames

Asked 2 years ago, Updated 2 years ago, 56 views

en = ['a', 'b', 'c']

ko = ["Ga", "Na", "Da"]

df = pd.DataFrame (data = [[ko, en]], columns = ['Hangul', 'English'])

df

I want to put a list in one column, but [] brackets go in together. Is there a way to get rid of the brackets and get in neatly?

python list dataframe pandas

2022-09-21 12:04

1 Answers

>>> df = pd.DataFrame (data = [[ko, en], columns = ['Hangul', 'English'])
>>> df
          Korean and English
0 [A, B, C] [a, b, c]
>>> df = pd.DataFrame (data = list (zip(ko, en)), columns = ['Hangul', 'English'])
>>> df
  Korean and English
0 is a
1 for me, b
Two. C
>>> df = pd.DataFrame ({ 'Hangul':ko, 'English':en})
>>> df
  Korean and English
0 is a
1 for me, b
Two. C


2022-09-21 12:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.