Python脚本

  • L2_397982
    了解作者
  • 58.7KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 03:46
    上传日期
Python脚本
Python-Scripts-master.zip
  • Python-Scripts-master
  • Intermediate Python
  • main.py
    1.5KB
  • Selenium Modules
  • main.py
    886B
  • Advanced Python
  • decorators_adv.py
    632B
  • generators_adv.py
    625B
  • meta.py
    826B
  • main.py
    1.4KB
  • context_managers.py
    1.1KB
  • Socket
  • server.py
    1.6KB
  • client.py
    631B
  • Motion Sensing
  • main.py
    828B
  • covid19_plot
  • covid19_deaths.csv
    59.3KB
  • covid19_confirmed.csv
    75.4KB
  • analyzation.py
    4.4KB
  • covid19_recovered.csv
    63.1KB
  • OOPs
  • static_methods.py
    173B
  • inherit.py
    742B
  • class_attributes.py
    508B
  • oops.py
    996B
  • Threading Modules
  • test.py
    471B
内容介绍
import numpy as np import pandas as pd import matplotlib.pyplot as plt import bs4 confirmed = pd.read_csv('covid19_confirmed.csv') deaths = pd.read_csv('covid19_deaths.csv') recovered = pd.read_csv('covid19_recovered.csv') confirmed_new = confirmed.drop(['Province/State', 'Lat', 'Long'], axis=1) confirmed_new = confirmed_new.groupby(confirmed_new['Country/Region']).aggregate('sum') deaths_new = deaths.drop(['Province/State', 'Lat', 'Long'], axis=1) deaths_new = deaths_new.groupby(deaths_new['Country/Region']).aggregate('sum') recovered_new = recovered.drop(['Province/State', 'Lat', 'Long'], axis=1) recovered_new = recovered_new.groupby(recovered_new['Country/Region']).aggregate('sum') confirmed_new = confirmed_new.T deaths_new = deaths_new.T recovered_new = recovered_new.T new_cases = confirmed_new.copy() for day in range(1, len(confirmed_new)): new_cases.iloc[day] = confirmed_new.iloc[day] - confirmed_new.iloc[day-1] growth_rate = confirmed_new.copy() for day in range(1, len(confirmed_new)): growth_rate.iloc[day] = (new_cases.iloc[day] / confirmed_new.iloc[day - 1]) * 100 active_cases = confirmed_new.copy() for day in range(0, len(confirmed_new)): active_cases.iloc[day] = confirmed_new.iloc[day] - deaths_new.iloc[day] - recovered_new.iloc[day] overall_growth_rate = confirmed_new.copy() for day in range(1, len(confirmed_new)): overall_growth_rate.iloc[day] = (active_cases.iloc[day] - active_cases.iloc[day - 1]) / active_cases.iloc[day - 1] * 100 death_rate = confirmed_new.copy() for day in range(0, len(confirmed_new)): death_rate.iloc[day] = (deaths_new.iloc[day] / confirmed_new.iloc[day]) * 100 hospitalization_rate_estimate = 0.05 hospitalization_needed = confirmed_new.copy() for day in range(0, len(confirmed_new)): hospitalization_needed.iloc[day] = active_cases.iloc[day] * hospitalization_rate_estimate countries = ['Italy', 'US', 'India', 'France', 'Spain', 'China', 'United Kingdom'] ax = plt.subplot() ax.set_facecolor('black') ax.figure.set_facecolor('#121212') ax.tick_params(axis='x', colors='white') ax.tick_params(axis='y', colors='white') ax.set_title('Covid-19_Total Confirmed Cases in Countries', color='white') for country in countries: confirmed_new[country][30:].plot(label=country) plt.legend(loc='upper left') plt.show() for country in countries: ax = plt.subplot() ax.set_facecolor('black') ax.figure.set_facecolor('#121212') ax.tick_params(axis='x', colors='white') ax.tick_params(axis='y', colors='white') ax.set_title(f'Covid-19_Total Confirmed Cases day/day in {country}', color='white') confirmed_new[country].plot.bar() plt.show() for country in countries: ax = plt.subplot() ax.set_facecolor('black') ax.figure.set_facecolor('#121212') ax.tick_params(axis='x', colors='white') ax.tick_params(axis='y', colors='white') ax.set_title(f'Covid-19_Total Confirmed Cases Growth rate in {country}', color='white') growth_rate[country].plot.bar() plt.show() ax = plt.subplot() ax.set_facecolor('black') ax.figure.set_facecolor('#121212') ax.tick_params(axis='x', colors='white') ax.tick_params(axis='y', colors='white') ax.set_title('Covid-19_Total Death in Countries', color='white') for country in countries: deaths_new[country].plot(label=country) plt.legend(loc='upper left') plt.show() for country in countries: ax = plt.subplot() ax.set_facecolor('black') ax.figure.set_facecolor('#121212') ax.tick_params(axis='x', colors='white') ax.tick_params(axis='y', colors='white') ax.set_title(f'Covid-19_Total Death rate in {country}', color='white') death_rate[country].plot.bar() plt.show() """ simulated_growth_rate = 0.03 dates = pd.date_range(start='4/22/2020', periods=40, freq='D') dates = pd.Series(dates) dates = dates.dt.strftime('%m/%d/%Y') simulated = confirmed_new.copy() simulated = simulated.append(pd.DataFrame(index=dates)) for day in range(len(confirmed_new), len(confirmed_new)+40): simulated.iloc[day] = simulated.iloc[day-1] * (1 + simulated_growth_rate) for country in countries: ax = plt.subplot() ax.set_facecolor('black') ax.figure.set_facecolor('#121212') ax.tick_params(axis='x', colors='white') ax.tick_params(axis='y', colors='white') ax.set_title(f'Future Simulation for {country}', color='white') simulated[country].plot() plt.show() """ # estimated_death_rate = 0.025 # estimated infected = deaths / estimated death rate
评论
    相关推荐
    • Python
      Python
    • python
      Python 这是用于大多数基本和简单python代码的示例模板的存储库。
    • Python
      Python项目 Python是一些简单的Python项目,它是一种解释性的高级通用编程语言,我愿意学习它为将来的许多项目做出贡献! 入门 您必须安装Python 3.9.2才能尝试这些项目。 这些项目来自各种书籍,您可以根据需要进行...
    • Python
      Python Dit是Mijn储存库van Python
    • python
      Python 基本的python编程
    • Python
      Python python和pyspark
    • python
      关于python的学习资料。。。。。。。
    • python学习
      python学习 安装Python 我们转到Python页面进行初始下载:( )在为Mac OSX选择了最新版本(3.9.2)之后,我将其下载到了我的计算机上。 然后,我们搜索了“ Python入门”,并确认VS Code是适用于Python的可行代码...
    • Fluent Python
      This book was written for practicing Python programmers who want to become proficient in Python 3. If you know Python 2 but are willing to migrate to Python 3.4 or later, you should be fine. At the ...
    • Python
      Python 该存储库包含与Python编程研究相关的文档