Skip to content
Snippets Groups Projects
Commit 60ce9206 authored by Max Väistö's avatar Max Väistö
Browse files

Merge branch 'demo_picture'

parents 249b19a5 a831097b
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,8 @@ import pandas
import pandas as pd
from main import get_steam_API_response, get_steamspy_API_response, STEAM_SPY_GAME_INFO, STEAM_API_LANGUAGE, \
STEAM_GAME_INFO_URL, replace_owner_number_with_symbol
STEAM_GAME_INFO_URL
from dash_plot_generation.utils import replace_owner_number_with_symbol_real_numeric
def get_dlc_data_steam(id):
......@@ -90,7 +91,7 @@ if __name__ == "__main__":
data = pandas.read_csv(os.path.join(os.getcwd(), path, file_name), index_col=0)
# data = data.iloc[0:10] # for testing
full_df = get_dlc_for_df(data)
full_df = replace_owner_number_with_symbol(full_df)
full_df = replace_owner_number_with_symbol_real_numeric(full_df)
file_name = "".join(["dlc_data", "_", str(file_index), ".csv"])
file_path = os.path.join(os.getcwd(), dlc_path, file_name)
......
......@@ -11,6 +11,8 @@ import numpy
import matplotlib.pyplot as plt
from pandas.core.dtypes.common import is_numeric_dtype
from dash_plot_generation.utils import replace_owner_number_with_symbol_real_numeric
STEAMSPY_ALL_GAMES_URL = "https://steamspy.com/api.php?request=all&page="
STEAM_GAME_INFO_URL = "https://store.steampowered.com/api/appdetails?appids="
STEAM_API_LANGUAGE = "&l=english"
......@@ -178,17 +180,6 @@ def create_hist_plots(df):
plt.show()
def replace_owner_number_with_symbol(df):
def owner_strip(user_range: str):
if isinstance(user_range, str):
user_range = user_range.replace(",000,000", " M")
user_range = user_range.replace(",000", " k")
return user_range
df["owners"] = df["owners"].apply(lambda name: owner_strip((name)))
return df
def create_heat_maps(df, plot_pairs):
for (x, y) in plot_pairs:
plt.figure() # Create a new figure for each heatmap
......@@ -229,7 +220,7 @@ if __name__ == "__main__":
for i in range(0, 68):
df = get_all_data(iterations=[i])
df = add_user_rating(df)
df = replace_owner_number_with_symbol(df)
df = replace_owner_number_with_symbol_real_numeric(df)
df = price_to_dollars(df)
file_name = "".join(["game_data", "_", str(i), ".csv"])
file_path = os.path.join(os.getcwd(), path, file_name)
......
dash_plot_generation/dash_assets/background_image.jpg

131 KiB

dash_plot_generation/dash_assets/broken car.jpg

116 KiB

dash_plot_generation/dash_assets/dark city.jpg

102 KiB

dash_plot_generation/dash_assets/dark_computer_room.jpg

98.2 KiB

dash_plot_generation/dash_assets/radioactive.jpg

120 KiB

html, body {
height: 100%;
margin: 0;
background-color: rgb(27,40,56);
}
#app-container {
height: 100%;
width: 100%;
position: relative;
}
.ag-theme-custom-dark {
--ag-background-color: #ddd !important;
}
.dash-dropdown .Select-control {
border: 2px solid rgb(37, 55, 77);
border-radius: 4px;
}
.dash-dropdown .Select-value {
color: rgb(235, 235, 235);
}
.dash-dropdown .Select-control {
background-color: rgb(50, 70, 101);
}
.dash-dropdown.is-minimized .Select-value-label {
color: rgb(235, 235, 235);
}
.dash-dropdown .Select-value-label {
color: rgb(235, 235, 235);
}
.dash-dropdown .Select-menu-outer {
background-color: rgb(50, 70, 101);
}
.jsx-4017309047.tab-container{
border-bottom: 2px solid rgb(37,55,77);
}
.dark_plot{
background-color: black;
}
/* Track rgb(197,195,192) */
div.scrollable::-webkit-scrollbar {
width: 6px; /* width of the vertical scrollbar */
border-radius: 6px;
}
div.scrollable::-webkit-scrollbar-track {
margin-top: 20px;
margin-bottom: 20px;
}
div.scrollable::-webkit-scrollbar-thumb {
background-color: rgb(235, 235, 235);
border-right: none;
border-left: none;
border-radius: 6px;
}
div.scrollable::-webkit-scrollbar-track-piece:end {
background: rgb(37,55,77);
margin-bottom: 10px;
}
div.scrollable::-webkit-scrollbar-track-piece:start {
background: rgb(37,55,77);
margin-top: 10px;
}
\ No newline at end of file
This diff is collapsed.
import math
import re
from typing import Sequence, Optional, Any
import pandas
DEFAULT_ILLEGAL_CONTINUATIONS = {"INC.", "LLC", "CO.", "LTD.", "S.R.O."}
def get_owner_means(owner_limits: Sequence[Any]):
if not isinstance(owner_limits, list):
return owner_limits
else:
return (owner_limits[0] + owner_limits[1]) / 2
def convert_owners_to_limits(owner_limit):
if not isinstance(owner_limit, str):
return owner_limit
owners_raw = [rev.replace(" ", "") for rev in owner_limit.split(" .. ")]
owners_clean = []
for owner_limit in owners_raw:
owner_limit = owner_limit.replace("M", "0" * 6)
owner_limit = owner_limit.replace("k", "0" * 3)
owners_clean.append(int(owner_limit))
return owners_clean
def split_companies(arr, illegal_continuations: Optional[Sequence[str]] = None):
"""
Splits the given string at comma sign as long as following the comma none of the illegal
continuations happen. In such a case, the string split does not happen that said comma.
:param arr: Array containing the developers/publishers for a single game
:param illegal_continuations: A list of illegal continuations. Must be uppercase.
:return: Returns the given split input string as a list.
:note: If the arr is numpy.NaN, this value is returned instead of a list.
"""
if illegal_continuations is None:
illegal_continuations = DEFAULT_ILLEGAL_CONTINUATIONS
if pandas.isna(arr):
return arr
results_list = []
start_index = 0
split_char = ", "
for index in range(len(arr)):
if index < len(arr) - 1:
txt = arr[index:index + 2]
if txt == split_char:
found_illegal = False
min_continuation = min([len(continuation) for continuation in illegal_continuations])
max_continuation = max([len(continuation) for continuation in illegal_continuations])
next_chars = arr[index + min_continuation:index + min_continuation + max_continuation]
for i in range(index + min_continuation, index + len(next_chars) + 2):
comp_txt = arr[index + 2:i + 2].upper()
if comp_txt in illegal_continuations:
found_illegal = True
break
if not found_illegal:
results_list.append(arr[start_index:index].strip())
start_index = index + 1
elif index == len(arr) - 1:
results_list.append(arr[start_index:index + 1].strip())
return results_list
def extract_unique_companies(nested_companies):
full_company_list = [dev for company_list in nested_companies
if isinstance(company_list, list) for dev in company_list]
unique_companies = []
for company in full_company_list:
if company not in unique_companies:
unique_companies.append(company)
return unique_companies
def replace_owner_number_with_symbol(df):
def owner_strip(user_range: str):
if isinstance(user_range, str):
user_range = user_range.replace(",000,000", " M")
user_range = user_range.replace(",000", " k")
return user_range
df["owners"] = df["owners"].apply(lambda name: owner_strip((name)))
return df
def replace_owner_number_with_symbol_real_numeric(value):
value_str = str(value)
value_str = re.sub("0" * 9 + "$", " billion", value_str)
value_str = re.sub("0" * 6 + "$", " million", value_str)
# value_str = re.sub("0" * 3 + "$", " thousand", value_str)
return value_str
def update_dots(n):
num_dots = (n % 10) + 1
dots = "." * num_dots
return [dots]
def convert_to_numeric_str(value, **kwargs):
return replace_owner_number_with_symbol_real_numeric(round_to_three_largest_digits(value, **kwargs))
def label_with_rev(label, rev, space, char=".", currency_symbol=""):
processed_rev = convert_to_numeric_str(int(rev))
return_val = label_with_text(label, "".join([currency_symbol, processed_rev]), space, char)
return return_val
def label_with_text(first_str, second_str, space, char="."):
white_space_filler = char * (space - (len(first_str) + len(second_str)) - 2)
return_val = " ".join([first_str, white_space_filler, second_str])
return return_val
def round_to_three_largest_digits(number, accuracy=2):
round_val = -(len(str(round(number))) - accuracy)
return_val = round(round(number), min(round_val, 0))
return return_val
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment