# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + id="nMsssoxhzgB-" colab_type="code" colab={}
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

# + id="5zFWIDfXzmtm" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 34} outputId="4bac0d17-dd28-410e-f25c-ba7df256c2ed" executionInfo={"status": "ok", "timestamp": 1583246169408, "user_tz": -60, "elapsed": 627, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "12005924092811763252"}}
# cd "/content/drive/My Drive/Colab Notebooks/dw_matrix2/dw_matrix_car"

# + id="7ruLdMiH0t45" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 270} outputId="aa04213d-81f3-4e13-cbfd-9d53526ed6d7" executionInfo={"status": "ok", "timestamp": 1583246152845, "user_tz": -60, "elapsed": 6808, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "12005924092811763252"}}
# !pip install --upgrade tables

# + id="wR0ysyI7zs6O" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 34} outputId="2bda4e40-cebb-49c2-b902-49a8437b838f" executionInfo={"status": "ok", "timestamp": 1583246183135, "user_tz": -60, "elapsed": 2524, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "12005924092811763252"}}
df = pd.read_hdf('data/car.h5')
df.shape

# + id="kEO4CrZjzyag" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 1000} outputId="b0d94c2d-9d8a-4c1f-9afc-5838c259650a" executionInfo={"status": "ok", "timestamp": 1583247833480, "user_tz": -60, "elapsed": 607, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "12005924092811763252"}}
df.columns.values

# + id="VQ_Tehez1HCL" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 282} outputId="11a0f421-0861-489e-f8cd-d08df8a49827" executionInfo={"status": "ok", "timestamp": 1583246334398, "user_tz": -60, "elapsed": 777, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "12005924092811763252"}}
df['price_value'].hist(bins = 100)

# + id="2YaTNcf91XHw" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 168} outputId="69a67c8c-ed42-48af-86dd-857d32d9e22f" executionInfo={"status": "ok", "timestamp": 1583246365197, "user_tz": -60, "elapsed": 634, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "12005924092811763252"}}
df['price_value'].describe()


# + id="Wev9rh251k8K" colab_type="code" colab={}
#przekazujemy średnią/medianę w sposób dynamiczny
#mediana jest bardziej odporna na wartości odstające
def group_and_barplot(feat_groupby, feat_agg = 'price_value', agg_funcs = [np.mean, np.median, np.size], feat_sort = 'mean', top = 100, subplots = True):
  return (
    df
    .groupby(feat_groupby)[feat_agg]
    .agg(agg_funcs)
    .sort_values(by=feat_sort, ascending = False)
    .head(top)
  ).plot(kind = 'bar', figsize = (15, 5), subplots = subplots)


# + id="lVdznRW218-O" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 417} outputId="52d69839-6cc2-4990-ab96-4298b72aa836" executionInfo={"status": "ok", "timestamp": 1583247778056, "user_tz": -60, "elapsed": 2331, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "12005924092811763252"}}
group_and_barplot('param_marka-pojazdu');

# + id="j6OjW9S26mdn" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 414} outputId="27579f02-9846-438d-abbe-a517093869bd" executionInfo={"status": "ok", "timestamp": 1583249035601, "user_tz": -60, "elapsed": 1559, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "12005924092811763252"}}
group_and_barplot(['param_rodzaj-paliwa'], feat_sort = 'mean');

# + id="7hNbAkKm7WwX" colab_type="code" colab={}


StarcoderdataJupyterScriptsDedupFiltered