python - from_records - Convertir lista a columna Pandas Dataframe
pandas dataframe from_records (1)
Necesito convertir mi lista en un marco de datos de pandas de una columna
Lista actual (len = 3):
[''Thanks You'',
''Its fine no problem'',
''Are you sure'']
Pandas DF requeridos (forma = 3,):
0 Thank You
1 Its fine no problem
2 Are you sure
Tenga en cuenta que los números representan el índice en Pandas DF requeridos arriba.
Utilizar:
L = [''Thanks You'', ''Its fine no problem'', ''Are you sure'']
#create new df
df = pd.DataFrame({''col'':L})
print (df)
col
0 Thanks You
1 Its fine no problem
2 Are you sure
df = pd.DataFrame({''oldcol'':[1,2,3]})
#add column to existing df
df[''col''] = L
print (df)
oldcol col
0 1 Thanks You
1 2 Its fine no problem
2 3 Are you sure
Gracias DYZ :
#default column name 0
df = pd.DataFrame(L)
print (df)
0
0 Thanks You
1 Its fine no problem
2 Are you sure