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

Get mean of specific columns with same name from multiple dataframe and put into a list

I have multiple data frames with the same column names. How can I get the mean of specific columns ( let’s say the column name I want to get is similarity ) from all data frames and put them into a list?

DF1

   similarity     count
0     0.2           2
1     0.1           3
2     0.46          4
3     0.12          8
4     0.6           10

DF2

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


   similarity     count
0     0.2           4
1     0.1           3
2     0.46          5
3     0.12          6
4     0.6           9

Expected Output

[ 0.296, 0.296 ]

>Solution :

I’d use a list comprehension.

[df.similarity.mean() for df in [df1, df2]]
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