Compute the mean of certain column for each class

import pandas as pd import numpy as np #df is a Dataframe, and mean_column is the column you want to compute mean for. df.pivot_table(index="class_column",values="mean_column",aggfunc=np.mean)
Use pivot_table method to compute the mean of certain column for each class.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.