[[+content_image]]
G
G
GreenX52020-09-12 05:29:33
Python
GreenX5, 2020-09-12 05:29:33

Python Pandas how to calculate the average of multiple DataFrame?

There is a list of several dataframes of the same type with the same dates.

import pandas as pd

dfs=[
    pd.DataFrame([['2020-08-13','John', 30],
                  ['2020-08-14','John', 20],
                  ['2020-08-15','John', 35]],
                columns=['id','name', 'value']),

    pd.DataFrame([['2020-08-13','Mike', 10],
                  ['2020-08-14','Mike', 25],
                  ['2020-08-15','Mike', 5]],
                columns=['id','name', 'value']),

    pd.DataFrame([['2020-08-13','Ken', 8],
                  ['2020-08-14','Ken', 17],
                  ['2020-08-15','Ken', 10]],
                columns=['id','name', 'value'])
]


How to create a resultant with the calculation of arithmetic averages by dates?

like this

pd.DataFrame([['2020-08-13','mean', среднее на дату],
              ['2020-08-14','mean', среднее на дату],
              ['2020-08-15','mean', среднее на дату]],
            columns=['id','name', 'value'])

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question