Calculate Mean in Python (5 Examples) | pandas DataFrame & NumPy library | Get Row Average by Group

preview_player
Показать описание
Python code of this video:

my_list = [1, 4, 6, 1, 3, 1, 4, 5] # Create example list
print(my_list) # Print example list

import numpy as np # Load NumPy

import pandas as pd # Import pandas library in Python

data = pd.DataFrame({'x1':[6, 2, 7, 5, 3, 7, 2, 7, 9], # Create pandas DataFrame
'x2':range(0, 9),
'group':['A', 'B', 'B', 'A', 'A', 'C', 'C', 'B', 'A']})
print(data) # Print pandas DataFrame

print(data['x1'].mean()) # Get mean of one column

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

great video, but when i try to find the mean of an specific column i get this error: Series.mean does not implement numeric_only. how can i solve it? (the column has missing data as '?'). i did replace those values by a numeric value '0' but still.

fernnadoarturo
Автор

How can we eliminate date numeric values while calculating mean

shwetalakhera
Автор

brother how can get the mean median from a txt file? is it possible?

mdrezoanul