Guest User

Untitled

a guest
Jun 21st, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. 1---> -6month
  2. 2---> -1 year
  3. 3--->-1.5 year
  4. .
  5. .
  6. .
  7.  
  8. dffinal = df[['6month','final-formula','Question Text','numPatients6month']].drop_duplicates().sort_values(['6month'])
  9.  
  10. df = dffinal.drop('numPatients6month', 1).groupby(['6month','Question Text']).sum().unstack('Question Text')
  11.  
  12. df.columns = df.columns.droplevel()
  13. ax=df.plot(kind='bar', stacked=True)
  14. import matplotlib.pyplot as plt
  15. ax2 = ax.twinx()
  16. plt.xticks(fontsize=8, rotation=45)
  17. #ax2.spines['right'].set_position(('axes', 1.0))
  18. dffinal.plot(ax=ax2,x='6month', y='numPatients6month',visible=False)
  19. plt.title('Cognitive Impairement-Stack bar')
  20. plt.show()
  21.  
  22. dffinal['6month'].replace(1, '-6 month',inplace=True)
  23. dffinal['6month'].replace(2, '-1 year',inplace=True)
Add Comment
Please, Sign In to add comment