Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17217

Unpivot/merging column values with a summarization in pandas df [duplicate]

$
0
0

I have a df that looks similar to this right now:

enter image description here

What I would like to do is to group by Name, Number and Year, summarize Amount, and then create a single new column that has all Countries based on that grouping, or a new column for each country (the number of which would have to be dynamic as the number of countries differs for each Name in the dataset). So the final df would look like one of the below:

enter image description here

or

enter image description here


Viewing all articles
Browse latest Browse all 17217

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>