I'd like to convert each cell of dataframe to list
import pandas as pd
a=[619, 200, 50, 45]
dic={"a":a}
df = pd.DataFrame.from_dict(dic)
#Output should be like this:
a
[619]
[200]
[50]
[45]
Use:
df["a"] = df["a"].apply(lambda x: [x])
print(df)
Output
a
0 [619]
1 [200]
2 [50]
3 [45]
Or:
df["a"] = [[x] for x in df["a"]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With