I have the following code.
I want to go through the 'outlierdataframe' dataframe row by row and explode the values in the 'x' and 'y' columns.
For each exploded row, I then want to store this exploded row as its own dataframe, with columns 'newID', 'x' and 'y'.
However, the following code prints everything in one column rather than printing the exploded 'x' values in one column, the exploded 'y' values in another column?
I would be so grateful for a helping hand!
individualframe = outlierdataframe.iloc[0]
individualoutliers = individualframe.explode(list('xy'))
newframe = pd.DataFrame(individualoutliers)
print(newframe)
outlier dataframe first line:
indexing first line of outlier dataframe:
outlierdataframe.iloc[0]
index 24
subID Prolific_610020
level 1
complete False
duration 20.015686
map_view 12.299759
distance 203.426697
x [55, 55, 55, 60, 60, 60, 65, 70, 70, 75, 80, 8...
y [60, 60, 60, 60, 65, 65, 70, 70, 75, 75, 80, 8...
r [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1...
batch 1
newID 610020
Name: 24, dtype: object
newframe = pd.DataFrame(individualoutliers)
print(newframe)
24
0 24
1 Prolific_610020
2 1
3 False
4 20.015686
.. ...
121 55
122 55
123 55
124 1
125 610020
