0

Table description

I want to replace the values of the columns A, B, C, D with the values where region = '' for the a unique value for the year 2011. For example, the unique column with the value 1 for 2011 will replace its 3, 4, 9, 8 values with 6, 6, 6, 6; this approach would then be applied to the unique values 2 and 3. Afterwards the rows where region = '' would be dropped.

Other questions related to this don't have the answers I am looking for. I have tried using loc but to no avail.

1 Answer 1

1

I think you need this:

df=df.groupby(['unique','year']).agg('last').reset_index()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.