Bar plot and proportion from data - 11:00 AM

edited February 1 in Assignments

(10 points)

Using your own random data from last week's forum question, let's use Colab to examine the activity_level variable. Specifically:

  • Generate a bar chart for activity_level and
  • Compute the proportion of folks whose activity level is high.

Note that creative burden is higher in this lab than in the last in that the Colab link above leads to a blank notebook. Nonetheless, you can find sample code that should help in our class presentation on Categorical Data.

Comments

  • edited February 1

    I got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=audrey')
    

    I then generated a table for activity_level like so:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    high 39
    moderate 33
    none 28

    I can now see the proportion is
    $39/100 = 0.39$.

    Finally, I generated my bar chart like so:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    My data looked like this:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=michaela')
    df.head()
    

    I isolated the activity level with this code:

    value_counts = df['activity_level'].value_counts()
    value_counts
    #. Output: moderate     42
              high            30
              none           28
    

    So now I can see the proportion of high activity level to all participants is:

    $30/100 = 0.3$

    Here is my bar chart

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    I got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=keoni')
    

    I then generated a table for 'activity level' like so:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    high 37
    moderate 27
    none 36

    I can now see that the proportion is
    $37/100=0.37$

    Finally, I generated my bar chart like so:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    I got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=Mpallozzi')
    

    I then generated a table for 'activity_level' like so:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    high 40
    moderate 33
    none 27

    I can now see the proportion is

    $40/100 = 0.40$.

    Finally, I generated my bar chart like so:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • I got my data using this code

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=PinetreeStar')
    

    Then I generated a bar chart for 'activity_level' with this code

    value_counts = df['activity_level'].value_counts()
    value_counts.plot.bar()
    

    I can now see the proportion is

    $27/100 = 0.27$

    mark
  • edited February 1

    I got my data using this Code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=anthonyaversano')
    df.head()
    

    I then generated a table for activity_level like so:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    Moderate 39
    High 34
    None 27

    I can now see the proportion is:

    $39/100$ = 0.39

    finally I generated my bar chart like so:

    value_counts.plot.bar(figsize=(12,7), rot = 0); 
    

    mark
  • edited February 1

    I got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=AnnaMagnes')
    

    I then generated a table for 'activity_level' using the code:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    moderate 44
    high 32
    none 24

    I can now see the proportion is
    $32/100 = 0.32$

    Finally, I generated my bar chart using this code:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • I got my data using this code

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=eriana')
    

    df.head()

    Then I generated a table for " activity _level" like so

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    high 39
    none 35
    moderate 26

    I can now see the proportion is
    $39/100$ = 0.39

    mark
  • I got my data using:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=sepidae')
    df.head()
    

    Then I generated a table for 'activity_level' by doing this:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    moderate 42
    high 30
    none 28

    Now, we can see the proportion is
    $42/100 = 0.42$

    And this is the bar chart:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • I got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=erinwalsh')
    

    I then generated a table for 'activity_level' like so:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    high 40
    moderate 30
    none 30

    I can now see the proportion is
    $40/100 = 0.40$.

    I generated my bar chart like so:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    Here is my bar chart:

    mark
  • edited February 1

    I got my data using code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv username=noah') df.head()
    

    I then generated a table for 'activity level' like so:

    value_counts = df['activity_level'].value_counts() value_counts
    

    none 37
    high 32
    moderate 31

    I can now see the proportion is:

    $32/100 = 0.32$

    Final, I generated my bar chart like so:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    I got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=blake')
    

    I then generated a table for"activity_level":

     value_counts = df['activity_level'].value_counts()
     value_counts
    

    moderate 36
    high 32
    none 32

    I can now see the proportion is
    $32/100=0.32$.

    finally, I generated my bar chart like so:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    I got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=Kylie')
    df.head()
    

    Then I generated a table for 'activity_level' with this code:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    None:36
    High:35
    Moderate:29

    I can now see the proportion is
    $35/100=0.35$

    Finally I generated my bar chart like this:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    I got my data using:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=pheebsjoy')
    df.head()
    

    then I generated a table for 'activity_level' like so:

    high        37
    moderate    36
    none        27
    Name: activity_level, dtype: int64
    

    I can now see the proportion is
    $37/100 =0.37$

    finally, I generated my bar chart like so:

      value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    i got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=ijurek')
    df.head()
    

    i generated a table for my data with this:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    high: 39
    moderate: 33
    none: 28

    the proportion is clearly:
    39/100 = .39

    here is my bar chart:

     value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    I got my data using this code

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=leahgiven1')
    df.head()
    

    I isolated the activity level with this code

    value_counts = df['activity_level'].value_counts()
    value_counts 
    

    none 40
    moderate 32
    high 28
    Name: activity_level, dtype: int64

    I can now see that my proportion is
    28/100= 0.28

    I generated my bar chart using the code

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1

    I got my data using this code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=evan')
    df.head()
    

    I then generated a table for activity_level like so:

    value_counts = df['activity_level'].value_counts()
    value_counts
    moderate    38
    high        34
    none        28
    

    I can now see the proportion is

    $34/100= 0.34$

    Finally, I generated my bar chart using this code:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • I got my data using code:

    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv? 
    username=MAA')
    df.head()
    

    I then generated a table for 'activity level' like so:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    none 43
    moderate 29
    High 28

    I can Now see the proportion is

    $43/100$

    I then created a bar graph:

    value_counts.plot.bar(figsize=(12,7), rot = 0);
    

    mark
  • edited February 1
    import pandas as pd
    df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=mpalmer2')
    

    I found the values like this:
    value_counts = df["activity_level"].value_counts()
    value_counts
    none-41
    moderate-30
    high-29

    I now see the proportion is
    29/100= 0.29

    Finally I generated my bar chart like so:
    value_counts.plot.bar(figsize=(12,7), rot = 0);

    mark
  • edited February 1

    I got my data using this code:

    import pandas as pd
     df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=yates')
    

    Then I generated a table for " activity _level" using the code:

    value_counts = df['activity_level'].value_counts()
    value_counts
    

    High 39
    None 35
    Moderate 26

    I can now see the proportion

    $39/100$ = .39

    Finally I generated my bar graph by using the code:

    value_counts.plot.bar(figsize=(12,7), rot = 0)
    

    mark
Sign In or Register to comment.