Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

How to find percentage of total with groupby pandas

$
0
0

@niranjan_283 wrote:

I have a csv data set with the columns like Sales,Last_region
i want to calculate the percentage of sales for each region, i was able to find the sum of sales with in each region but i am not able to find the percentage with in group by statement.

Groupby statement used

tempsalesregion = customerdata.groupby(["Last_region"])
tempsalesregion = tempsalesregion[["Customer_Value"]].sum().add_prefix("Sum_of_").reset_index()
tempsalesregion

Output is

image

But what i need is the percentage of sales per region,i am not able to figure out how to find that out.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles