Friday, August 14, 2020

Grouped Frequency Counts

Another common data-related task is to calculate frequencies. We can use the nunique and value_counts methods, respectively, to get counts of unique values and frequency counts on a Pandas Series.

# use the nunique (number unique)

# to calculate the number of unique values in a series

print(df.groupby('continent')['country'].nunique())

Output


Visualizations are extremely important in almost every step of the data process. They help us identify trends in data when we are trying to understand and clean the data, and they help us convey our final findings.

Let’s look at the yearly life expectancies for the world population again.

global_yearly_life_expectancy = df.groupby('year')['lifeExp'].mean()

print(global_yearly_life_expectancy)


We can use Pandas to create some basic plots as shown below


The graph above shows basic plots in Pandas showing average life expectancy over time. In the graph, the vertical axis represents "life expectancy" ranging from 50 to 67.5, in increments of 2.5. In the horizontal axis represents "years" ranging from 1960 to 2000, in increments of 10. In the graph, a line starts below 50.0 from the vertical axis that increases gradually.

Share:

0 comments:

Post a Comment