2
$\begingroup$

I have a group data frame like this :

group_by_region_year_month=train_data.groupby(['Region Name (GO)','Year','Month'],as_index=False)
    
    region_sum=group_by_region_year_month.agg({"AMV": "sum"})

Here, AMV is my target variable in regression (this is the count of total vehicles).

I have data for each day from 2000-3-17 to 2017-10-11.

I want to show the variation of the count for each year and each month for each Region.

How best can I plot it?

I tried using seaborn.FacetGrid in this way:

# g=sns.FacetGrid(row="Region Name (GO)", col="AMV", data=region_sum)

But it is taking too much time.

Is there any better alternative(s)?

Edit 1

I tried this :

sns.set(rc={'figure.figsize':(50,30)})

ax=sns.barplot(x='Region Name (GO)', y='AMV', hue='Year', data=train_data)
ax.set_xticklabels(ax.get_xticklabels(), rotation=90)

which gave me a very clumsy plot : Total vehicle count

I did not use countplot as countplot would give me a count of rows. But, I want the sum of all values in a group.

Can I represent it in any better way?

$\endgroup$
1
$\begingroup$

If you like using Seaborn to construct your plots, sns.countplot is probably the best for plotting data where you want to show the differences in value counts.

You can find the link to the documentation page here which might be helpful for you to construct it in the particular way you want.

As an example, here is a version of a "multiple" count plot like you suggest. (directly from the Seaborn Documentation page)

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.