<jupyter_start><jupyter_text>Initial EDA to investigate the Business (Use-)Case<jupyter_code>import numpy as np
import pandas as pd
import os
import glob

# Visualisation
import seaborn as sns
import matplotlib.pyplot as plt

# Global plot modification
%matplotlib inline
sns.set_theme(style="whitegrid")
sns.set_palette('rainbow')

#sns.set_theme(style="ticks", palette="pastel")
# Read data set
df = pd.read_csv('data/Kickstarter_cleaned.csv')

# Drop column
df = df.drop(['Unnamed: 0'], axis=1)

# Show head
df.head(2)
# Define decimal places shown
pd.options.display.float_format = '{:,.2f}'.format
#df.shape
#df.info()
#df.isnull().sum().sort_values(ascending=False)<jupyter_output><empty_output><jupyter_text>Heatmap<jupyter_code># Calculate correlations
corr = df.corr()

# Plot heatmap
mask = np.zeros_like(corr)
mask[np.triu_indices_from(mask)] = True
with sns.axes_style("white"):
    f, ax = plt.subplots(figsize=(6, 5))
    ax = sns.heatmap(corr, mask=mask, vmax=1, center=0, vmin=-1,
                     square=True, annot=True, fmt='.1f', cmap='YlGnBu', linewidth=0.1);<jupyter_output><empty_output><jupyter_text>'State'<jupyter_code>#df.state.unique()
# Data selection
state = df.state

# Plotting
sns.histplot(state, linewidth=0.1);

# Formating
plt.title('Projects by state', fontsize=13)
plt.xlabel('Project state', fontsize=10)
# Boxplot success and failure of projects by category, country, etc.<jupyter_output><empty_output><jupyter_text>'Category'<jupyter_code># Sort and count categories

#df.category_name.sort_values().unique()
#category_count = df.groupby('category_name')['id'].nunique().sort_values(ascending=False).iloc[0:10]
# Change dimension of the plot
fig, ax = plt.subplots(figsize=(10, 5))

# Plotting TOP 10
sns.countplot(y=df.category_name,
              order=df['category_name'].value_counts().sort_values(ascending=False).iloc[0:10].index,
             palette='rainbow');

# Formating
plt.title('TOP 10 categories', fontsize=15)
plt.xlabel('Count', fontsize = 12)
plt.ylabel('Category', fontsize = 12)<jupyter_output><empty_output><jupyter_text>'Goal' & 'Pledged Amount'<jupyter_code>#df.usd_pledged.unique()
#df.columns
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10, 5), constrained_layout=True)

# Plotting & Formating
sns.boxplot(x=df.usd_goal, palette='rainbow', ax=ax[0]);
ax[0].set_title('Pledging Goals', fontsize=13)
ax[0].set_xlabel('Goals in USD', fontsize=11)
ax[0].set_xlim(0, 35000)

sns.boxplot(x=df.usd_pledged, palette='rainbow', ax=ax[1]);
ax[1].set_title('Pledged amount', fontsize=13)
ax[1].set_xlabel('Pledged amount in USD', fontsize=11)
ax[1].set_xlim(0, 17500)<jupyter_output><empty_output><jupyter_text>Distribution<jupyter_code># Plotting
sns.distplot(a=df.usd_goal.apply(np.log));

# Formating
plt.title('Distribution of goal (log transformed)', fontsize=13)
plt.xlabel('Goal', fontsize=10)
df.usd_pledged
# Plotting
z = df.usd_pledged.astype(int)
sns.distplot(a=z);

# Formating
plt.title('Distribution of usd_pledged (log transformed)', fontsize=13)
plt.xlabel('usd_pledged', fontsize=10)
#plt.xscale('log')<jupyter_output>/Users/michaelleder/opt/anaconda3/envs/kickstarter/lib/python3.8/site-packages/seaborn/distributions.py:2551: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
  warnings.warn(msg, FutureWarning)<jupyter_text>'Country'<jupyter_code># df.country.value_counts()

# Plotting
sns.countplot(data=df, x='country', order=df['country'].value_counts().index,
              hue='state', palette='rainbow');

# Formating
plt.title('State by country', fontsize=13)
plt.xlabel('Country', fontsize=10)<jupyter_output><empty_output><jupyter_text>Time relation<jupyter_code># Christmas vs. Summer // Summer, winter

#sns.lineplot(data=df, x='', y='')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1542929292929293, 'fraction_numerical': 0.022474747474747474, 'mean_word_length': 6.82806324110672, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '638756', 'license': 'MIT', 'n_tokens_mistral': 1564, 'n_tokens_neox': 1474, 'n_words': 267, 'path': '002_initial_eda.ipynb', 'repo_name': 'jakoliendenhollander/2020-ds-Project02-Kickstarter', 'size': '3960'}