in Education by
I have the following df | 1 | 2 | 3 | ------------------------- 0.11 0.25 0.74 0.32 0.93 0.26 0.44 0.28 0.76 0.15 0.29 0.79 etc. I'm using bins: bins = [0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1] I created 3 bin columns and ran a value_counts() on them. So now I know how many values are in each bin for each of these 3 columns. But I'm having trouble plotting this into a barplot. Looking for a triple bar graph df['Bin1'] = pd.cut(df['1'], bins) df['Bin2'] = pd.cut(df['2'], bins) df['Bin3'] = pd.cut(df['3'], bins) Bin1_count = df['Bin1'].value_counts().values Bin2_count = df['Bin2'].value_counts().values Bin3_count = df['Bin3'].value_counts().values x_axis = df['Bin1'].value_counts().index sns.barplot(x = x_axis, y = [Bin1_count,Bin2_count,Bin3_count]) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can using melt first , then using pd.crosstab, and try look at plot from pandas meltdf=df.melt() meltdf.value=pd.cut(meltdf.value,bins) pd.crosstab(meltdf.variable,meltdf.value).plot(kind='bar')

Related questions

0 votes
    Working with census data, I want to replace NaNs in two columns ("workclass" and "native-country") with the ... way to do this? Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    when i want to execute below code and plot figer scatter_matrix(total_frame) total_frame is a dataframe like ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I have a 20 x 4000 dataframe in python using pandas. Two of these columns are named Year and quarter. I'd ... anyone help with that? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I created a dataframe and column labels in pandas and I need to edit in order to replace the original column ... names. Please help? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I wish to divide pandas dataframe to 3 separate sets. I know by using train_test_split from sklearn.cross_validation, ... ? kindly help Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    import pandas as pd from itertools import combinations, product, permutations MH_P= ["Maria Herrera"] OP_P= ["Oscar ... i solve it? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I'm starting with input data like this df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", ... Any hints would be welcome. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I want to get a list of the column headers from a pandas DataFrame. The DataFrame will come from user input so I don ... 'gdp', 'cap'] Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I want to select rows from a DataFrame based on values in some column in pandas, How can I do it? I ... WHERE column_name = some_value Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I have a dataframe as below itm Date Amount 67 420 2012-09-30 00:00:00 65211 68 421 2012-09-09 00 ... solutions would be appreciated. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I'm trying to get the number of rows of dataframe df with Pandas, and here is my code. Method 1: total_rows ... What am I doing wrong? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I'm working on this script that first takes all .csv's and converts them .xlsx's in a separate ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    I'm working on this script that first takes all .csv's and converts them .xlsx's in a separate ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    An irregular time series data is stored in a pandas.DataFrame. A DatetimeIndex has been set. I need the ... seemingly simple operation? Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    I am trying to groupby a column and compute value counts on another column. import pandas as pd dftest = pd. ... Amt, already exists Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
...