Skip to content

Instantly share code, notes, and snippets.

View Thiagobc23's full-sized avatar

Thiago Bernardes Carvalho Thiagobc23

View GitHub Profile
@Thiagobc23
Thiagobc23 / countries
Last active April 9, 2021 19:53
List of countries from world bank for cleaning datasets
# countries from https://data.worldbank.org/country
all_countries = ['Afghanistan', 'Albania', 'Algeria', 'American Samoa',
'Andorra', 'Angola', 'Antigua and Barbuda', 'Argentina',
'Armenia', 'Aruba', 'Australia', 'Austria', 'Azerbaijan',
'Bahamas, The', 'Bahrain', 'Bangladesh', 'Barbados',
'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda',
'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana',
'Brazil', 'British Virgin Islands', 'Brunei Darussalam',
'Bulgaria', 'Burkina Faso', 'Burundi', 'Cabo Verde',
'Cambodia', 'Cameroon', 'Canada', 'Cayman Islands',
@Thiagobc23
Thiagobc23 / gantt.py
Created August 30, 2021 02:46
Gantt chart with Matplotlib
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
from pandas import Timestamp
##### DATA #####
data = {'Task': {0: 'TSK M',
1: 'TSK N',
2: 'TSK L',
@Thiagobc23
Thiagobc23 / gantt.py
Last active March 30, 2024 16:54
Gantt Chart with Matplotlib v2
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
from pandas import Timestamp
##### DATA #####
data = {'Task': {0: 'TSK M',
1: 'TSK N',
2: 'TSK L',
@Thiagobc23
Thiagobc23 / smooth_chart.py
Last active October 28, 2021 03:14
Smooth line chart with Matplotlib (scipy interpolate)
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import interpolate
url = 'https://gist.githubusercontent.com/Thiagobc23/4ccb4ea1c612d9d68921bf990ce28855/raw/6225824a6b7d5d273019c09c25cbbaa5b82009bc/dummy_data.csv'
df = pd.read_csv(url, index_col='ID')
# figure
fig, ax = plt.subplots(1, figsize=(12,4), facecolor='#293952')
@Thiagobc23
Thiagobc23 / secondary_axis.py
Last active November 2, 2021 02:21
Matplotlib line charts with secondary axis | dual-axis | double-axis
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
url = 'https://gist.githubusercontent.com/Thiagobc23/4ccb4ea1c612d9d68921bf990ce28855/raw/6225824a6b7d5d273019c09c25cbbaa5b82009bc/dummy_data.csv'
df = pd.read_csv(url, index_col='ID')
# figure
fig, ax = plt.subplots(1, figsize=(12,4), facecolor='#293952')
ax.set_facecolor('#293952')
@Thiagobc23
Thiagobc23 / connected_scatter.py
Last active November 2, 2021 02:25
Connected Scatter Plot with Matplotlib
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
import numpy as np
import pandas as pd
url = 'https://gist.githubusercontent.com/Thiagobc23/4ccb4ea1c612d9d68921bf990ce28855/raw/6225824a6b7d5d273019c09c25cbbaa5b82009bc/dummy_data.csv'
df = pd.read_csv(url, index_col='ID')
# figure
# data
@Thiagobc23
Thiagobc23 / ridge_plot.py
Created November 2, 2021 04:38
Ridge plot with Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# DATA
url = 'https://gist.githubusercontent.com/Thiagobc23/4ccb4ea1c612d9d68921bf990ce28855/raw/07af955c17d1816aba58dea74d65f60210702a15/film.csv'
df = pd.read_csv(url, index_col='ID')
# Theme
sns.set_theme(style="white", rc={"axes.facecolor": (0, 0, 0, 0), 'axes.linewidth':2})
@Thiagobc23
Thiagobc23 / circular_progress_bar.py
Created November 3, 2021 01:53
Circular progress bar with Matplotlib
from math import pi
import numpy as np
from matplotlib.patches import Patch
from matplotlib.lines import Line2D
# data and variables
data = [82, 75, 91]
startangle = 90
colors = ['#4393E5', '#43BAE5', '#7AE6EA']
@Thiagobc23
Thiagobc23 / donut.py
Last active November 3, 2021 01:58
Donut chart with Matplotlib
import matplotlib.pyplot as plt
data = [87,13]
fig, ax = plt.subplots(figsize=(6, 6))
wedgeprops = {'width':0.3, 'edgecolor':'black', 'linewidth':3}
ax.pie(data, wedgeprops=wedgeprops, startangle=90, colors=['#5DADE2', '#515A5A'])
plt.title('Worldwide Access to Electricity', fontsize=24, loc='left')
@Thiagobc23
Thiagobc23 / magnus.csv
Last active January 10, 2022 02:04
Magnus Carlsen Historical Fide Rating - Standard
Rating Date
2865 2022-01-01
2856 2021-12-01
2855 2021-11-01
2855 2021-10-01
2855 2021-09-01
2847 2021-08-01
2847 2021-07-01
2847 2021-06-01
2847 2021-05-01