# Poniendo las librerías
from datetime import datetime
import logging
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import session_info
logging.basicConfig(
format = '%(message)s',
level=logging.DEBUG,
encoding="utf-8"
)
df = pd.read_csv('kcsep22.csv')
logging.info(f'En total hay {df.shape[0]} usuarios registrados')
SELECT
'ZeroTG' AS Servers,
SUM(CASE WHEN zerotg THEN 1 ELSE 0 END) AS Duelistas
FROM
df
UNION ALL
SELECT
'ZephraCarl' AS Servers,
SUM(CASE WHEN zephra THEN 1 ELSE 0 END) AS Duelistas
FROM
df
UNION ALL
SELECT
'Bryan Norén' AS Servers,
SUM(CASE WHEN bryan THEN 1 ELSE 0 END) AS Duelistas
FROM
df
UNION ALL
SELECT
'Xenoblur' AS Servers,
SUM(CASE WHEN xenoblur THEN 1 ELSE 0 END) AS Duelistas
FROM
df;
comunidad = comunidad.sort_values('Duelistas', ascending=0)
comunidad['Relación al Total'] = (
comunidad.Duelistas / df.shape[0]
).apply('{:.0%}'.format)
fig = px.bar(comunidad, y='Duelistas', x="Servers",
title="Registro de decks con su comunidad",
text="Relación al Total", color="Servers", template="ggplot2")
import plotly.graph_objects as go
fig.add_indicator(
mode="number",
value=df.shape[0],
title="Total de Duelistas",
number={'font': {'size': 50}},
domain = {'x': [0.75, .95], 'y': [0.75, .95]})
fig.update_layout(showlegend=False)
fig.show()
df['Día'] = pd.DatetimeIndex(df['ndmax']).day
ndmax_fer_day = (
df.groupby(['Día'])['Día'].count()
.reset_index(name='Duelistas'))
fig = px.line(
ndmax_fer_day, x="Día", y="Duelistas",
title="Usuarios que llegan a NDmax por día", text="Duelistas", template='ggplot2')
fig.update_yaxes(range=[0, 50])
fig.update_traces(textposition="top center")
fig.show()
logging.info(f'En promedio suelen tardar hasta el día {round(df.Día.mean())} para llegar a ndMAX')
resume = (
df.groupby(['deck','skill'])['skill'].size()
.reset_index(name='total')
.sort_values('total', ascending=0)
)
meklord = resume.query("deck=='Meklord'")
pecas = resume.query("deck=='Phantom Knights'")
rose_dragon = resume.query("deck=='Rose Dragon'")
galaxy_eyes = resume.query("deck=='Galaxy-Eyes'")
e_heros = resume.query("deck=='Elemental Heros'")
topfive=pd.concat([e_heros, galaxy_eyes, rose_dragon, pecas, meklord], ignore_index=True)
fig = px.bar(topfive, y='deck', x="total", color="skill",
title="Top Decks NDmax KC CUP Septiembre 2022", text="total",
orientation='h', template="ggplot2")
fig.update_layout(showlegend=False, xaxis_title="Total", yaxis_title="Decks")
fig.show()
logging.info(f'De {df["deck"].nunique()} arquetipos distintos este el top 5')
deck_variety_skill = (
df.groupby(['deck'])['skill'].nunique()
.reset_index(name='total')
.sort_values('total', ascending=0)
)
deck_variety_skill.query("total>2")
logging.info('su lista de Habilidades del top 2')
skill_df = resume.copy()
skill_df["all"] = "su lista de Habilidades del top 2"
fig = px.treemap(
skill_df.query("deck=='Heros' or deck=='Magnet Warrios'"),
path=['all', 'deck', 'skill'], values='total')
fig.update_layout(title='Mazos con distintas Habilidades', title_x=0.5,
margin = dict(t=50, l=25, r=25, b=25))
fig.show()
logging.info('Esta tabla representa la skill que se encuentra en distintos arquetipos')
skill_distint_deck = (
df.groupby(['skill'])['deck'].nunique()
.reset_index(name='total')
.sort_values('total', ascending=0)
)
skill_distint_deck.query("total>2")
logging.info('Tabla de todos los mazos que usan Robo del Destino')
fig = px.treemap(
skill_df.query("skill=='Robo del Destino'"),
path=['skill', 'deck'], values='total')
fig.update_layout(
title='Tabla de todos los mazos que usan Robo del Destino',
title_x=0.5,
margin = dict(t=50, l=25, r=25, b=25)
)
fig.show()
logging.info("Reporte finalizado")
# Actualizado a junio 2023
session_info.show()