Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Dive Deeper into Visualization | Explore Dataset
Introduction to Python for Data Analysis
course content

Conteúdo do Curso

Introduction to Python for Data Analysis

Introduction to Python for Data Analysis

1. Introduction to Python 1/2
2. Introduction to Python 2/2
3. Explore Dataset
4. Becoming an Analyst

bookDive Deeper into Visualization

Let's imagine that it is essential for you to sort out the user continued subscription after the trial period. Let's move to the dataset that we use, for example:

Look at the code:

12345678910
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/783d7288-e86b-4b89-9966-a2fe97995277/section_2_dataset_upd.csv', index_col = 0) df = df.groupby(['plan', 'trial']).sum().reset_index() sns.barplot(data = df, x = 'plan', y = 'price', hue = 'trial') plt.show()
copy

As you can see, we just add the hue parameter, which helps you sort out data by categories. For instance, here, hue = 'trial', the column 'trial' has two categories: True and False.

And here is the output:

barplot

Tarefa

Visualize the sum of money you receive from users depending on their subscription plan. Take into account if the user continued the subscription after the trial period.

  1. Import the seaborn with the sns alias.
  2. Import the matplotlib.pyplot with the plt alias.
  3. Prepare data for visualization using the .groupby() function:
  • Extract columns 'plan', 'price', 'trial' for grouping
  • Group by column 'plan' and then by 'trial'.
  • Calculate the sum of all prices for each plan.
  • Reset indices.
  1. Create the barplot using the seaborn:
  • Use df as the data argument.
  • Use the 'plan' column for x-axis.
  • Use the 'price' column for y-axis.
  • Use the 'trial' column for hue variable.
  1. Display the plot.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 17
toggle bottom row

bookDive Deeper into Visualization

Let's imagine that it is essential for you to sort out the user continued subscription after the trial period. Let's move to the dataset that we use, for example:

Look at the code:

12345678910
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/783d7288-e86b-4b89-9966-a2fe97995277/section_2_dataset_upd.csv', index_col = 0) df = df.groupby(['plan', 'trial']).sum().reset_index() sns.barplot(data = df, x = 'plan', y = 'price', hue = 'trial') plt.show()
copy

As you can see, we just add the hue parameter, which helps you sort out data by categories. For instance, here, hue = 'trial', the column 'trial' has two categories: True and False.

And here is the output:

barplot

Tarefa

Visualize the sum of money you receive from users depending on their subscription plan. Take into account if the user continued the subscription after the trial period.

  1. Import the seaborn with the sns alias.
  2. Import the matplotlib.pyplot with the plt alias.
  3. Prepare data for visualization using the .groupby() function:
  • Extract columns 'plan', 'price', 'trial' for grouping
  • Group by column 'plan' and then by 'trial'.
  • Calculate the sum of all prices for each plan.
  • Reset indices.
  1. Create the barplot using the seaborn:
  • Use df as the data argument.
  • Use the 'plan' column for x-axis.
  • Use the 'price' column for y-axis.
  • Use the 'trial' column for hue variable.
  1. Display the plot.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 17
toggle bottom row

bookDive Deeper into Visualization

Let's imagine that it is essential for you to sort out the user continued subscription after the trial period. Let's move to the dataset that we use, for example:

Look at the code:

12345678910
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/783d7288-e86b-4b89-9966-a2fe97995277/section_2_dataset_upd.csv', index_col = 0) df = df.groupby(['plan', 'trial']).sum().reset_index() sns.barplot(data = df, x = 'plan', y = 'price', hue = 'trial') plt.show()
copy

As you can see, we just add the hue parameter, which helps you sort out data by categories. For instance, here, hue = 'trial', the column 'trial' has two categories: True and False.

And here is the output:

barplot

Tarefa

Visualize the sum of money you receive from users depending on their subscription plan. Take into account if the user continued the subscription after the trial period.

  1. Import the seaborn with the sns alias.
  2. Import the matplotlib.pyplot with the plt alias.
  3. Prepare data for visualization using the .groupby() function:
  • Extract columns 'plan', 'price', 'trial' for grouping
  • Group by column 'plan' and then by 'trial'.
  • Calculate the sum of all prices for each plan.
  • Reset indices.
  1. Create the barplot using the seaborn:
  • Use df as the data argument.
  • Use the 'plan' column for x-axis.
  • Use the 'price' column for y-axis.
  • Use the 'trial' column for hue variable.
  1. Display the plot.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Let's imagine that it is essential for you to sort out the user continued subscription after the trial period. Let's move to the dataset that we use, for example:

Look at the code:

12345678910
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/783d7288-e86b-4b89-9966-a2fe97995277/section_2_dataset_upd.csv', index_col = 0) df = df.groupby(['plan', 'trial']).sum().reset_index() sns.barplot(data = df, x = 'plan', y = 'price', hue = 'trial') plt.show()
copy

As you can see, we just add the hue parameter, which helps you sort out data by categories. For instance, here, hue = 'trial', the column 'trial' has two categories: True and False.

And here is the output:

barplot

Tarefa

Visualize the sum of money you receive from users depending on their subscription plan. Take into account if the user continued the subscription after the trial period.

  1. Import the seaborn with the sns alias.
  2. Import the matplotlib.pyplot with the plt alias.
  3. Prepare data for visualization using the .groupby() function:
  • Extract columns 'plan', 'price', 'trial' for grouping
  • Group by column 'plan' and then by 'trial'.
  • Calculate the sum of all prices for each plan.
  • Reset indices.
  1. Create the barplot using the seaborn:
  • Use df as the data argument.
  • Use the 'plan' column for x-axis.
  • Use the 'price' column for y-axis.
  • Use the 'trial' column for hue variable.
  1. Display the plot.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 3. Capítulo 17
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
some-alt