To calculate the average of selected rows based on criteria of a dataframe in Python, you can use the mean() function.
Method: Use mean() Function
dataframe.loc[condition].mean() The
To calculate the mean by group of a dataframe in Python, you can use the groupby() and mean() functions.
Method: Use groupby() and mean() Functions
dataframe.groupby('group')['column1'].mean() The
To capitalize a string in Python, you can use the capitalize(), upper(), or title() functions.
The following examples show how to capitalize a string in Python.
Using
To center text in Python, you can use the str.center() function or the format() function.
The following examples show how to center text in Python.
Using str.center()