How can I extract the first, second, and 3rd elements from all rows? There are 4217 rows.
Here is my code:
0 [38, 24, 35]
1 [38, 24, 35]
2 [34, 24, 35]
3 [34, 26, 38]
4 [34, 26, 38]
...
4212 [34, 27, 35]
4213 [35, 32, 38]
4214 [34, 27, 35]
4215 [32, 24, 34]
4216 [37, 29, 39]
Name: element_size, Length: 4217, dtype: object
I tried this df.element_size[0] but only got this [38, 24, 35]
CodePudding user response:
You can do
pd.DataFrame(df['elements'].tolist())
For asscess the single item in list
df['elements'].str[0]