Skip to content
Advertisement

Pandas get elements from a column containing list of values using index slicing

Posting minimal reproducible example

I have a dataframe say

JavaScript

I need to create a new column where values will be only from the alternate index.

JavaScript

This is what I tried, but this does not work

JavaScript

P.S : There are numerous ways in which this can be achieved I am looking for a more pandaic approach

Advertisement

Answer

You may need to check your cell type is list if not do ast

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement