Skip to content

Instantly share code, notes, and snippets.

View ebergam's full-sized avatar

Enrico Bergamini ebergam

  • Barcelona
View GitHub Profile
# -*- coding: utf-8 -*-
import sys, re, time, logging, requests
import random
import unicodecsv as csv
from threading import Thread, Lock, currentThread
from queue import Queue, Empty
from lxml import html
lock = Lock()
@ebergam
ebergam / movingscatter.py
Last active May 15, 2019 11:09
Moving Scatter
graph = px.scatter(df, x="employment", y="equity", #color="country",
hover_name="country", text="countrycode",
range_x=[48,80], range_y=[76,93], template="plotly_dark", size="pop",
animation_group="country", animation_frame="year",
labels=dict(employment="Emp", equity="Eq",year="Year"))
for i in graph['data']:
i['name'] = i['name'].replace('Country=', '')
import pandas as pd
import os
import matplotlib.pyplot as plt
import missingno as msno
## The script merges and reshapes the data provided by https://github.com/kylemcdonald/covid-mobility-data
## Assumes all tsv files are in a folder called "archive"
## Inputs different files, outputs longform tidy data.
bdf = pd.read_csv('archive/2020-03-29_ES_Mobility_Report_en.pdf.tsv', sep='\t', nrows=0)
@ebergam
ebergam / google_trends.ipynb
Created October 9, 2020 08:48
Make queries from Gtrends and create time series
@ebergam
ebergam / ecb_indexer.py
Created January 9, 2021 12:13
Indexer for ECB press releases
from bs4 import BeautifulSoup as bs
import re, requests, time
from lxml import html
links = []
for date in range(1998, 2020+1):
url = 'https://www.ecb.europa.eu/press/pressconf/{}/html/index_include.en.html'.format(date)
r = requests.get(url)
tree = html.fromstring(r.content)