A little problem that leads me to two (or even 3) questions. And I have some difficulties to google the answer.
Here the very simple example :
>>> import pandas as pd
>>> my_list = [1,2,3]
>>> year = 2023
>>> item = 'obj'
>>> res_dict = {"year" : year, "values" : my_list, "name" : item }
>>> print(res_dict)
{'year': 2023, 'values': [1, 2, 3], 'name': 'obj'}
>>> df = pd.DataFrame(res_dict)
>>> print(df)
year values name
0 2023 1 obj
1 2023 2 obj
2 2023 3 obj
My problem that I want a slightly different DataFrame.
My first idea was to create a DataFrame where in values we store a list. So something like this :
year values name
0 2023 [1, 2, 3] obj
But, and here is the first question : it seems that while it's possible to put list into cell of DataFrame it"s not really a good idea. If it's so...
The second question. How could I instead create a DataFrame with columns for each element of my list ? To get something like this :
year values1 values2 values3 name
0 2023 1 2 3 obj