Hi i have a dataframe like
A
{1,2,3..1000}
I want to covert it into
A B C..ZZZ
1 2 3..10000
How can i split values in the array to different columns?
Hi i have a dataframe like
A
{1,2,3..1000}
I want to covert it into
A B C..ZZZ
1 2 3..10000
How can i split values in the array to different columns?
Use df.join:
import itertools
import string
names = list(
itertools.chain(
string.ascii_uppercase,
(''.join(pair) for pair in itertools.product(string.ascii_uppercase, repeat=3))
))
df = pd.DataFrame([[range(1,1000)]],columns=['A'])
df = df.join(pd.DataFrame(df["A"].apply(pd.Series))).drop('A',axis=1)
df.columns=names[:999]
Assuming your df to be this:
In [924]: df = pd.DataFrame({'A': [{1,2,3}]})
In [925]: df
Out[925]:
A
0 {1, 2, 3}
You can do this:
In [935]: result = pd.DataFrame(df.A.tolist())
In [936]: result
Out[936]:
0 1 2
0 1 2 3