python只保留数据的某几列_用Python只需要三分钟即可精美地可视化COVID-19数据

Matplotlib可能是Python的事实数据可视化库,但它并不总是最漂亮的。在本文中,我们将探讨如何将单调的默认Matplotlib图变成漂亮的数据可视化。我们将探索COVID-19数据,以了解该病毒如何在不同国家传播(我们只是针对数据进行分析不对任何做出评价)。

我们将使用来Github存储库中的数据,这个存储库每天会自动更新各国数据。我们将根据URL将数据加载到Pandas的数据框中,以便每天自动为我们更新。

# Section 1 - Loading our Librariesimport pandas as pdimport matplotlib.pyplot as pltfrom matplotlib.dates import DateFormatterimport matplotlib.ticker as ticker%matplotlib inline #if you're working in a Jupyter notebook# Section 2 - Loading and Selecting Datadf = pd.read_csv('https://raw.githubusercontent.com/datasets/covid-19/master/data/countries-aggregated.csv', parse_dates=['Date'])countries = ['Canada', 'Germany', 'United Kingdom', 'US', 'France', 'China']df = df[df['Country'].isin(countries)]# Section 3 - Creating a Summary Columndf['Cases'] = df[['Confirmed', 'Recovered', 'Deaths']].sum(axis=1)
895e5cc858c73667c39b744a1c115b8f.png
b1c92d3f5fba0f73acc9575c60c168be.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值