text_plain_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

import numpy as np
import pandas as pd
pd.set_option('display.max_columns', 50)
import os
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns

TRAIN_PATH = '/kaggle/input/hr-analytics-job-change-of-data-scientists/aug_train.csv'
TEST_PATH = '/kaggle/input/hr-analytics-job-change-of-data-scientists/aug_test.csv'

df = pd.read_csv(TRAIN_PATH)

print(f"Dataset has {len(df['city'].dropna().unique())} unique cities.")
print("_"*20)
print(f"Unique cities count:\n{df['city'].value_counts()}")
print("*"*50, end="\n\n")

fig, ax = plt.subplots(figsize=(12, 6))
sns.barplot(ax=ax, x=df['city'].value_counts().index[:10], y=df['city'].value_counts().values[:10], capsize=.2,palette="Blues_d")

def plotPerColumnDistribution(df, nGraphShown, nGraphPerRow):
    nunique = df.nunique()
    df = df[[col for col in df if nunique[col] > 1 and nunique[col] < 50]]
    nRow, nCol = df.shape
    columnNames = list(df)
    nGraphRow = (nCol + nGraphPerRow - 1) / nGraphPerRow
    plt.figure(num=None, figsize=(6 * nGraphPerRow, 8 * nGraphRow), dpi=80, facecolor='w', edgecolor='k')
    for i in range(min(nCol, nGraphShown)):
        plt.subplot(nGraphRow, nGraphPerRow, i + 1)
        columnDf = df.iloc[:, i]
        if not np.issubdtype(type(columnDf.iloc[0]), np.number):
            valueCounts = columnDf.value_counts()
            valueCounts.plot.bar()
        else:
            columnDf.hist()
        plt.ylabel('counts')
        plt.xticks(rotation=90)
        plt.title(f'{columnNames[i]} (column {i})')
    plt.tight_layout(pad=1.0, w_pad=1.0, h_pad=1.0)
    plt.show()
plotPerColumnDistribution(df, 10, 5)