Skip to content

Instantly share code, notes, and snippets.

View lucharo's full-sized avatar
🪐

Luis Chaves Rodriguez lucharo

🪐
  • London
  • 03:57 (UTC +01:00)
View GitHub Profile
a b c
1 0 One
2 0 Two
3 0 Three
import pandas as pd
pd.DataFrame({'a': [1,2,3], 'b': [0,0,0], 'c': ['One', 'Two', 'Three']})
@lucharo
lucharo / hide_cell.py
Created March 12, 2021 18:10
nb2medium-article
# %hide-cell
print("This cell won't make it to the final document")
@lucharo
lucharo / hide_output.py
Created March 12, 2021 18:10
nb2medium-article
# %hide-output
print("This code will be shown, but it's output won't")
@lucharo
lucharo / hide_source.py
Created March 12, 2021 18:10
nb2medium-article
# %hide-source
print("This code won't be shown, but it's output will")
@lucharo
lucharo / seaborn.py
Created March 12, 2021 18:10
nb2medium-article output
import seaborn as sns
x = np.arange(0, 10, 0.1)
y = np.sin(x)
sns.scatterplot(x = y,y = x);
@lucharo
lucharo / matplotlib.py
Created March 12, 2021 18:10
nb2medium-article output
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 10, 0.1)
y = np.sin(x)
plt.plot(x,y);
@lucharo
lucharo / nb2medium-upload.py
Created March 12, 2021 18:10
nb2medium-article output
from nb2medium.upload import nb2medium
nb2medium(title = 'My First Article', notebook = 'path/to/notebook.ipynb');
@lucharo
lucharo / fig_layout.py
Last active October 6, 2020 16:42
Populate plotly.graph_objects.Figure['layout']
fig['layout'] = go.Layout(
font = {'size' : 14},
plot_bgcolor = 'white',
xaxis = {'showline': True,
'visible': True,
'range': (0, data['Value'].max()),
'title_text': 'Production Quantity (tonnes)' # title of the x axis
},
yaxis = {'showline': False,
'visible': True, # to show the title
@lucharo
lucharo / fig_data.py
Last active October 6, 2020 16:41
Populate plotly.go.Figure['data']
#1 Assign color to each unique item
from random import sample
colors = {item: 'rgb({}, {}, {})'.format(*sample(range(256), 3)) for item in data['Item'].unique()}
data['color'] = data['Item'].map(colors)
#2 Slice data, select earliest date available
##2.1 Select earliest year available
frame1 = data[data['Year'] == data['Year'].min()]