Skip to content
Advertisement

How to get a value in a column as an index

I assign the eligible index value to A column and then df.ffill()

Now I want to use the value of A column as an index and assign the obtained value to the expcted column

I try df['expected']=df['price'][df['A']] but it doesn’t work.

input

JavaScript

expected result table

JavaScript

Advertisement

Answer

Try this:

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