Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Select how much data the pd.mean() displays?

When returning the pd.mean(), how to show only specific information?

Example

Now it gives this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

new_df = pd.read_excel('example.xls', usecols = ['weight'] )
print('avg value for column weight is here: '+ str(data.mean()))

Result

avg value for column weight is here: weight 2311.000000 dtype: float64

it should return:

avg value for column weight is here: 2311.000000

>Solution :

For avoid one value Series select column weight. If use Series.mean – call function for one column get scalar output:

print('avg value for column weight is here: '+ str(data['weight'].mean()))

Or use f-strings for same ouput:

print(f'avg value for column weight is here: {data["weight"].mean()}')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading