covid.py 560 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sun Aug 2 15:14:52 2020
  4. @author: Samir
  5. """
  6. import pandas as pd
  7. import matplotlib.pylab as plt
  8. import numpy as np
  9. import statsmodels.api as sm
  10. covid = pd.read_csv ("https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv")
  11. country = covid[covid.iso_code == 'USA']
  12. y = country['new_cases']
  13. x = np.arange(len(y))
  14. result = sm.OLS(y, x).fit()
  15. coef = np.polyfit(x,y,1)
  16. poly1d_fn = np.poly1d(coef)
  17. plt.plot(x,y, x, poly1d_fn(x), '--k')
  18. print(result.summary())
  19. print(result.summary2())