Skip to content

Instantly share code, notes, and snippets.

View Ze1598's full-sized avatar

José Fernando Costa Ze1598

  • Porto, Portugal
View GitHub Profile
@Ze1598
Ze1598 / quotespy_gen_graphics_quotes.py
Last active June 1, 2020 18:05
quotespy: gen_graphics example with quotes
import quotespy.graphics.graphics as g
custom_settings = {
"font_family": "Inkfree.ttf",
"font_size": 200,
"size": [3840, 2160],
"color_scheme": ["#000000", "#ffffff"],
"wrap_limit": 32,
"margin_bottom": 250,
}
@Ze1598
Ze1598 / quotes.txt
Created June 1, 2020 17:58
quotespy: quotes.txt sample
[mistakes]
Some mistakes and, dare I say, failures may lead to results you had never thought you could achieve
[strange days]
Say goodbye to the silence, we can dance to the sirens
@Ze1598
Ze1598 / quotes.json
Created June 1, 2020 17:56
quotespy: quotes.json sample
{
"mistakes": "Some mistakes and, dare I say, failures may lead to results you had never thought you could achieve",
"strange_days": "Say goodbye to the silence, we can dance to the sirens"
}
@Ze1598
Ze1598 / quotespy_graphics_custom_settings.py
Created June 1, 2020 17:36
quotespy: basic quotespy.graphics usage with custom graphic settings
import quotespy.graphics.graphics as g
graphic_info = {
"title": "strange_days",
"text": "Say goodbye to the silence, we can dance to the sirens"
}
custom_settings = {
"font_family": "Inkfree.ttf",
"font_size": 250,
@Ze1598
Ze1598 / quotespy_graphics_basic.py
Created June 1, 2020 17:29
quotespy: basic quotespy.graphics usage
import quotespy.graphics.graphics as g
graphic_info = {
"title": "strange_days",
"text": "Say goodbye to the silence, we can dance to the sirens"
}
g.create_graphic(graphic_info, {}, default_settings_format="lyrics")
@Ze1598
Ze1598 / cat_strings_usage.py
Created May 4, 2020 15:09
Handle Categorical data with pandas (str): usage
options = ["terrible", "bad", "so-so", "good", "excellent"]
map_options = [1, 2, 3, 4, 5]
evaluations = create_evaluations(options, map_options, 200)
plot_column_chart(
evaluations,
options,
"Evaluations' frequency",
["Evaluations", None],
@Ze1598
Ze1598 / bin_floats_usage.py
Last active May 4, 2020 15:27
Bin data using custom intervals with pandas (floats): usage
work_hours = pd.Series(np.random.random_sample(200,)) * 72 + 8
work_hours_binned = bin_work_hours(work_hours)
plot_histogram(
work_hours_binned,
10,
"Work Week Hours binned",
["Work week hours", None]
)
@Ze1598
Ze1598 / bin_integers_usage.py
Last active May 4, 2020 15:27
Bin data using custom intervals with pandas (integers): usage
ages = pd.Series(np.random.randint(low=0, high=99, size=200))
ages_binned = bin_ages(ages)
plot_histogram(
ages_binned,
10,
"Ages binned",
["Ages", None]
)
@Ze1598
Ze1598 / cat_strings.py
Last active May 4, 2020 15:09
Handle Categorical data with pandas (str)
import pandas as pd
import numpy as np
import plotly.express as px
from typing import List, Union
def create_evaluations(
categories: List[str],
mapping_values: List[str],
length: int
@Ze1598
Ze1598 / bin_floats.py
Last active May 4, 2020 15:27
Bin data using custom intervals with pandas (floats)
import pandas as pd
import numpy as np
import plotly.express as px
from typing import List, Union
def bin_work_hours(work_hours_series: pd.Series) -> pd.Series:
work_hours_labels = [f"[{i}, {i+8})" for i in range(8, 73, 8)]
work_hours_bins = pd.IntervalIndex.from_tuples(