Question:
I have a dataframe like as belowa) create 4 year columns
year_2019,year_2020,year_2021 and year_2022
.b) put the count of records for each
ID
under the respective year
columnsI tried the below
My real dataframe has 4 million rows and has 50 unique year values.(from 1970 to 2022)
But I want the count of year values only for 2019,2020,2021 and 2022.
I expect my output to be like as below
Answer:
You can use:If you have better answer, please add a comment about this, thank you!