This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import calendar | |
import pandas as pd | |
[...] | |
df["day_of_the_week"] = pd.Categorical(df["day_of_the_week"], list(calendar.day_abbr)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# my empirical distribution (it could be a numpy array) | |
mydistr = [...] | |
# calculate histogram weights | |
weights = np.ones_like(distr)/float(len(distr)) | |
# custom binning (just an example with 0.1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ax.annotate(my_text, xy=(arrow_x,arrow_y), xytext=(text_x,text_y), | |
arrowprops=dict(facecolor='gray', shrink=0.05)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
pd.options.display.max_columns = 40 | |
pd.options.display.max_rows = 999 | |
#details here: https://pandas.pydata.org/pandas-docs/stable/options.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas | |
import io | |
import gzip | |
import boto3 | |
csv_buffer = io.StringIO() | |
my_df.to_csv(csv_buffer, index=False) | |
csv_buffer.seek(0) | |
gz_buffer = io.BytesIO() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# horizontal line | |
ax.axhline(0.5, color="gray") | |
# vertical line | |
ax.axvline(0.5, color="gray") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# new solution (N is the number of elements) | |
ax.set_prop_cycle('color',plt.cm.rainbow(np.linspace(0,1,N))) | |
# the solution below is deprecated | |
cm = plt.get_cmap('gist_rainbow') | |
ax.set_color_cycle([cm(1.*i/len(YOUR_LIST)) for i in np.arange(len(YOUR_LIST))]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UNIX_TIMESTAMP(timestamp) | |
FROM_UNIXTIME(timestamp, "format") |