Skip to content

Instantly share code, notes, and snippets.

resampled_df_m = df_no_refund.resample('M', on='Date').sum().reset_index()
treemap2_df = resampled_df_m.copy()
treemap2_df['treeroot'] = 'Monthly Expense'
treemap2_df['Month'] = treemap2_df.Date.dt.month_name()
fig = px.treemap(
treemap2_df,
path=['treeroot', 'Month'],
values = 'Total',
title = 'Distribution of Steam Spending by Month',
)
import os
if not os.path.exists("images"):
os.mkdir("images")
import plotly.express as px
import plotly.io as pio
pio.kaleido.scope.default_format = "png"
pio.kaleido.scope.default_width = "1024"
pio.kaleido.scope.default_height = "768"
@max-torch
max-torch / bssoupblog4.py
Last active May 21, 2021 10:57
bssoupblog4
resampled_df_m = df_no_refund.resample('M', on='Date').sum().reset_index()
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_context('poster')
sns.set_style("darkgrid")
plt.figure(figsize = (16, 8))
ax = sns.barplot(data = resampled_df_m, x="Date", y="Total")
ax.set_xticklabels(resampled_df_m.Date.dt.month_name())
@max-torch
max-torch / bssoupblog3.py
Last active May 26, 2021 10:20
bssoupblog3
import pandas as pd
#Create dataframe from columns
Dict = {"Date": wht_date, "Items": wht_items, "Type": wht_type, "Total": wht_total}
df = pd.DataFrame.from_dict(Dict)
df.Date = pd.to_datetime(df.Date, infer_datetime_format=True)
df_no_refund = df[:-2]
@max-torch
max-torch / bssoupblog2.py
Last active May 27, 2021 08:38
bssoupblog
import re
wht_date = soup.select(".wht_date")
wht_date = [each.get_text() for each in wht_date[1:]]
wht_items = soup.select(".wht_items")
wht_items = [each.get_text().replace("\n", "_").replace("\t", "") for each in wht_items[1:]]
wht_type = soup.select(".wht_type")
wht_type = [each.get_text().replace("\n", "_").replace("\t", "") for each in wht_type[1:]]
@max-torch
max-torch / bssoupblog1.py
Last active May 20, 2021 18:13
Beautiful Soup load file
from bs4 import BeautifulSoup
soup = BeautifulSoup(open("your_file.html", encoding = 'utf8'), "html.parser")