<jupyter_start><jupyter_text>Covid<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import watermark
import requests

plt.style.use('./d4sci.mplstyle')
%matplotlib inline
%load_ext watermark
%watermark -n -v -m -g -iv
r = requests.get('https://www.worldometers.info/coronavirus/')
corona = pd.read_html(r.text)[0]
# corona.drop(['World','Total:'], inplace=True)
corona_total = corona.iloc[:1]
corona = corona.iloc[1:-1]
corona.rename(columns={
                    'Country,Other': 'Country',
              },
              inplace=True,
)

# Population by country
r = requests.get('https://www.worldometers.info/world-population/population-by-country/')
countr = pd.read_html(r.text)[0]
countr.rename(
            columns={
                     'Country (or dependency)': 'Country',
                     'Population (2020)': 'Population',
            },
            inplace=True,
)
# countr.replace(
countr['Country'].replace(
            to_replace={
                     'Central African Republic': 'CAR',
                     'Czech Republic (Czechia)': 'Czechia',
                     "Côte d'Ivoire": 'Ivory Coast',
                     'Saint Barthelemy': 'St. Barth',
                     'Saint Kitts & Nevis': 'Saint Kitts and Nevis',
                     'Saint Pierre & Miquelon': 'Saint Pierre Miquelon',
                     'South Korea': 'S. Korea',
                     'St. Vincent & Grenadines': 'St. Vincent Grenadines',
                     'State of Palestine': 'Palestine',
                     'United Arab Emirates': 'UAE',
                     'United Kingdom': 'UK',
                     'United States': 'USA',
            },
            inplace=True,
)

df = pd.merge(corona,
         countr[['Country', 'Population', 'Density (P/Km²)', 'Land Area (Km²)', 'Migrants (net)', 'Med. Age', 'Urban Pop %']],
         on='Country')

df.set_index('Country', inplace=True)

del corona
del countr

df.sort_values('TotalDeaths', ascending=False)<jupyter_output><empty_output><jupyter_text>[df.style.format](https://docs.python.org/3/library/string.htmlformat-specification-mini-language)<jupyter_code>df[df.TotalCases > df.loc['Czechia'].TotalCases].sort_values('TotalCases',ascending=False).style.format({'TotalCases': "{:,}", 'TotalDeaths': '{:,.0f}'})
df.loc['Czechia']
df.loc['Slovakia']
df[(df['Deaths/1M pop'] > df.loc['Czechia']['Deaths/1M pop']) & ((df.Population_x + df.Population_y) > 4e6)].sort_values('TotalDeaths',ascending=False)
# Zeman je debil...
df[(df.TotalCases >= 7000)].sort_values('Deaths/1M pop')
1 <= 2 < 3
#df[(df.Population < 12e6) & (df.TotalCases >= 500)].sort_values('Deaths/1M pop',ascending=False)
df[((df.Population_x + df.Population_x) > 2e6) & ((df.Population_x + df.Population_y) < 13e6) & (df.TotalCases >= 500)].sort_values('TotalTests',ascending=False)
df[['Population','TotalCases','TotalDeaths','NewDeaths','Serious,Critical']].sort_values('Population',ascending=False).head(15)<jupyter_output><empty_output><jupyter_text>POkusy<jupyter_code>import requests
from io import StringIO

r = requests.get('https://www.cia.gov/library/publications/resources/the-world-factbook/fields/rawdata_208.txt')
r.text
gdp = pd.read_html('https://www.cia.gov/library/publications/resources/the-world-factbook/fields/208rank.html')[0]
gdp[gdp['Country'] == 'Czechia']
pd.read_html('https://infographics.economist.com/2018/indicators/index.html/')
<table id="backPagesTable" class="sortable bpA"><thead 
import requests
from bs4 import BeautifulSoup

r = requests.get('https://infographics.economist.com/2018/indicators/index.html')
bs = BeautifulSoup(r.text, 'html.parser')
bs
bs.find(lambda tag: tag.name=='table' and tag.has_attr('id') and tag['id']=="backPagesTable") 
#rows = table.findAll(lambda tag: tag.name=='tr')
soup.find('table', { 'class' : 'table sortable bpA' })
# where the dictionary specify unique attributes for the 'table' tag
url = 'https://public.tableau.com/vizql/w/2603-koronavirus-okresy/v/krajJHM/vud/sessions/70F071E4508C4E86A331EF7E06C6023C-0:0/views/7713620505763405234_4509522748905601615?csv=true'
pd.read_csv(url,sep=';')
#['Kraj','Okres','Zkratka okresu','Počet nakažených na 100 000 obyvatel']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16919791172282866, 'fraction_numerical': 0.030612244897959183, 'mean_word_length': 3.6937639198218264, 'pattern_counts': {'":': 1, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '604832', 'license': 'MIT', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1447, 'n_words': 235, 'path': 'covid.ipynb', 'repo_name': 'loosak/pysnippets', 'size': '4214'}