I have a data frame that has persons affected by two different issues for each year from 1999 to 2005 as in bellow image.
dataframe
Can I create a bar chart that shows a comparison of person affected by cancer, Heart disease for each year?
Related
I have the following datasets:
df1 = {'lower':[3.99,4.99,5.99,1700], 'percentile':[1,2,5,10,50,100]}
df2 = {'lower':[2.99,4.50,5,1850], 'percentile':[2,4,7,15,55,100]}
The data:
The percentile refers to the percentage of the data that corresponds
to a particular price e.g: 3.99 would represent 1% of the data while
all values under 5.99 would represent 5% of the data.
The length of the two datasets is 100 given that we are showing percentiles, but they vary between the two datasets as the price.
What I have done so far:
What I need help with:
As you see in the third graph, I can plot the two datasets overlayed, which is what I need, but I have been unsuccessful trying to change the legend and the weird tick x values on the third graph. It is not showing the percentile, or other metrics I might use the x axis with.
Any help?
I am trying to make a plotly line chart that shows team member progression with the following excel data:
For the life of me I cannot figure out how to set the team member names as the color for the lines, the x-axis as the months, and the y-axis as the numeric values. Closest I've gotten is a blank graph, and I've tried about 400 combinations of parameters for
px.line(
df,
color="Team_Member",
x = "the row of months... something with iloc maybe?",
y = df.columns,
title="Average Estimated Daily Working Hours by Team Member"
)
I have a dataframe with 5 columns: salesman, vendor, product1, product2 and product3. The dataframe is similar to below:
I want to groupby salesman, loop through 'salesman' index and create a separate stacked bar chart for each salesman. For each stacked bar chart, I want x-axis to be the vendor and y-axis to stack on column values (i.e. product1/2/3 sales amount). Desired output:
Have tried several methods combined with for loop but keep getting error. Appreciate any guidance on this one! Thank you.
I am reading huge csv file using pandas module.
filename = pd.read_csv(filepath)
Converted to Dataframe,
df = pd.DataFrame(filename, index=None)
From the csv file, I am concerned with the three columns of name country, year, and value.
I have groupby the country names and sum the values of it as in the following code and plot it as a bar graph.
df.groupby('country').value.sum().plot(kind='bar')
where, x axis is country and y axis is value.
Now, I want to make this bar graph as a stacked bar and used the third column year with different color bars representing each year. Looking forward for an easy way.
Note that, year column contains years from 2000 to 2019.
Thanks.
from what i understand you should try something like :
df.groupby(['country', 'Year']).value.sum().unstack().plot(kind='bar', stacked=True)
I have a 10 rows x 26 columns data set of a country region's oil production between 1990-2011. The first column designates the country region (e.g. Canada), the next 22 columns correspond to oil production between 1990 and 2010, and the last two columns have ratios of oil production in one year relative to another.
My goal is to simply plot the oil production as a function of time separately for each country (i.e. categorize by column 1 and discard the last two columns when plotting). What is the most efficient way to do this?
It seems like you want all of the columns in your data except the last two, so use df.iloc[:, :-2] to select it. You then want to transpose this data so that the dates are now the row and the countries are the columns (use .T). Finally, plot your data.
df.iloc[:, :-2].T.plot()