Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Calculate the Mean and Median Salary | Mean, Median and Mode with Python
Learning Statistics with Python

book
Calculate the Mean and Median Salary

Compito

Swipe to start coding

Calculate the mean and median of the 'salary' column using the library of your choice, either numpy or pandas.

Soluzione

# Import library
import pandas as pd

df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/update/ds_salaries_statistics', index_col = 0)

# Calculating the mean value
mean = df['salary'].mean()
# Calculating the median value
median = df['salary'].median()

print('The mean value is', mean)
print('The median value is', median)
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 4
# Import library
___

df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/update/ds_salaries_statistics', index_col = 0)

# Calculating the mean value
mean = ___
# Calculating the median value
median = ___

print('The mean value is', mean)
print('The median value is', median)
toggle bottom row
some-alt