Я хочу преобразовать каждый столбец в dictionary
и, наконец, поместить все dictionary
в list
.
import pandas as pd
df= pd.DataFrame({'city': ['Dubai', 'London', 'San Fransisco'],
'temperature': [33, 12, 18,]})
print(df)
Output:
city temperature
0 Dubai 33
1 London 12
2 San Fransisco 18
Expected:
mylist = [
{'city': 'Dubai', 'temperature': 33},
{'city': 'London', 'temperature': 12},
{'city': 'San Fransisco', 'temperature': 18},
]