When doing data analysis with pandas module in python, I was trying to create a function that can apply the following process to a list of data frames. (Note: P1_Assessment
is one of the dataframes that I would like to analyse.)
P1_Assessment[P1_Assessment > 1].sum(axis=0).astype(int).sort_values(ascending = False).plot(kind = 'bar')`
So to analyse a list of data frames in one block of code, I tried to create a function as follows:
def assess_rep(dataframe):
for i in dataframe:
a = i[i > 1].sum(axis= 0).astype(int).sort_values(ascending = False)
a.plot(kind = 'bar')
return
But when I used the function on a list of dataframes, only the analysed result of the last dataframe was returned.
I tried to search on similar topics on stackoverflow but didn't come across anything, maybe I missed out. Any help on this is greatly appreciated!!