I'm receiving the following error:
File "/packages/pandas/core/common.py", line 380, in _asarray_tuplesafe
result[:] = [tuple(x) for x in values]
TypeError: 'numpy.int64' object is not iterable
When running:
df.apply(lambda row: (df2.append(([row]*(row[6].split(',').__len__())), ignore_index=True)), axis=1)
The goal is to apply for each origin dataframe row (df
) an append N times to an empty df (df2
). Where N is the number of values that the specific field row[6]
has.
Rows of example are for the df
:
Id|List
0|126
1|126,127,304,305
The df2
should be:
Id|List
0|126
1|126
1|127
1|304
1|305
As you can see I tried sending the row as a list, but don't work neither. Any idea?