Skip to content
Advertisement

Row wise operation in Pandas DataFrame

I have a Dataframe as

JavaScript

I would like to have a lambda function in apply method to create a list of dictionary (including index item) as below

JavaScript

If I use something like .apply(lambda x: <some operation>) here, x does not include the index rather the values.

Cheers, DD

Advertisement

Answer

To expand Hans Bambel’s answer to get the exact desired output:

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