I have a dataframe
IDs Types
0 1001 {251}
1 1013 {251, 101}
2 1004 {251, 701}
3 3011 {251}
4 1014 {701}
5 1114 {251}
6 1015 {251}
where df['Types'] has sets in each row. I want to convert this column into multiple columns such that I can get the following output
IDs Type1 Type2
0 1001 251 -
1 1013 251 101
2 1004 251 701
3 3011 251 -
4 1014 701 -
5 1114 251 -
6 1015 251 -
Currently, I am using the following code to achieve this
pd.concat([df['Types'].apply(pd.Series), df['IDs']], axis = 1)
But it return the following error
Traceback (most recent call last):
File "C:/Users/PycharmProjects/test/test.py", line 48, in <module>
df = pd.concat([df['Types'].apply(pd.Series), df['IDs']], axis = 1)
File "C:\Python\Python35\lib\site-packages\pandas\core\series.py", line 2294, in apply
mapped = lib.map_infer(values, f, convert=convert_dtype)
File "pandas\src\inference.pyx", line 1207, in pandas.lib.map_infer (pandas\lib.c:66124)
File "C:\Python\Python35\lib\site-packages\pandas\core\series.py", line 223, in __init__
"".format(data.__class__.__name__))
TypeError: 'set' type is unordered
Please guide me how can I get the desired output. Thanks