Home > Blockchain >  combining the information of several dataframes in boxplot
combining the information of several dataframes in boxplot

Time:11-15

I would like to generalize the problem raised by little in the post enter image description here


Complete code with dummy data frames for testing:

import pandas as pd
import numpy as np

##Creating dummy data

def dummy_data():
    N = np.random.randint(10,30)
    df = pd.DataFrame({'time_sec':list(range(N)),'heart_rate':np.random.randint(70,150,N)})
    return df

dfs = [dummy_data() for i in range(20)] #20 heart_rate datasets

#Assuming dfs is the list of pandas dataframes

combined = pd.concat([i.set_index('time_sec') for i in dfs], axis=1) #Set index as time and combine them
combined.columns = ['run_' str(i) for i in range(combined.shape[1])] #rename the columns
combined.boxplot(figsize=(15,5))                                     #Plot
  • Related