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

# # <NAME>

# ## Is there a correlation between the category of a startup, its success, and the most popular industry of a country?
#
# An example for my reserach question would be: Would media startups be more successful in Los Angeles than in Moscow?

import numpy as np
import pandas as pd
import matplotlib.pylab as plt
import seaborn as sns
from collections import Counter
# %matplotlib inline

sns.set_theme(style="ticks",
              font_scale=1.3, # This scales the fonts slightly higher
             )

# + tags=[]
df = pd.read_csv('../data/raw/ks-projects-201801.csv')

# + [markdown] tags=[]
# ## Milestone 3
# -

# In this milestone, I will manipulate with the data I have 

# ### Task 1. EDA

print("(Rows : Columns) respectively:", df.shape)
print("Columns in the dataset:", df.columns)

del df['ID']
del df['name']
del df['currency']
del df['deadline']
del df['goal']
del df['launched']
del df['pledged']
del df['usd pledged']

df.describe(include='float64').T

df.describe(include='object').T

df.state.unique()

df.main_category.unique()

# ### Task 2-3 Load Raw and Processed Data

import project_functions1 as pf1

# **1. Unprocessed File**

df = pd.read_csv('../data/raw/ks-projects-201801.csv')
df

# **2. Processed File**

# *In the processed file, I filtered the numbers of pledged money, goals, and backers. Also, some columns that are unnesessery are deleted*

# +
df_short = df[(df['usd_goal_real'] < 40000)
                   & (df['backers'] < 100)
                   & (df['usd_pledged_real'] < 15000)]
del df_short['ID']
del df_short['name']
del df_short['currency']
del df_short['deadline']
del df_short['goal']
del df_short['launched']
del df_short['pledged']
del df_short['usd pledged']

df_short
# -

# ### Task 4. Data Analysis

# In the plot below, I showed that with the filtering I made, all the countries had most of the attempts to create startups in different main categories 

df_short.plot(kind='scatter', x='state', y='main_category')
##With that plot, I can see that most of the countries created startups for all the categories, although I can also see that no "Journalism", "Dance", "Crafts" startups were created in JP Japan

# *I looked at the shape of the graph and made sure it is filtered*

# df_short.shape

# *I made sure I have all nesessary columns for the future analysis*

df_short.columns

# I checked if the United States still have the most attemts for startups

df_short['country'].value_counts().head()

# ## United States of America

# I decided to create some subsets of data where only one country is defined for the most popular category of the startups in the country. Therefore, the United states have a great music industry, which must be positively correlated with the number of successful startups

df_us_ind = df_short[df_short['country'].str.contains('US')]
df_us_ind = df_us_ind[df_us_ind.main_category == 'Music']
df_us_ind = df_us_ind[df_us_ind['state'].str.contains('canceled')==False]
df_us_ind = df_us_ind[df_us_ind['state'].str.contains('live')==False]
df_us_ind = df_us_ind[df_us_ind['state'].str.contains('suspended')==False]
df_us_ind.head()

# *I checked the statistics for successful vs failed startups*

df_us_ind['state'].value_counts()

sns.pairplot(df_us_ind)

sns.rugplot(df_us_ind['usd_pledged_real'])

sns.countplot(x='state',data=df_us_ind)

sns.kdeplot(df_us_ind['usd_pledged_real'])

#histograms for each variable in dataset
df_us_ind = df_us_ind.hist(bins=10,figsize =(10,10))

# + [markdown] jupyter={"source_hidden": true} tags=[]
# ## Great Britain
# -

df_gb_ind = df_short[df_short['country'].str.contains('GB')]
df_gb_ind = df_gb_ind[df_gb_ind.main_category == 'Publishing']
df_gb_ind = df_gb_ind[df_gb_ind['state'].str.contains('canceled')==False]
df_gb_ind = df_gb_ind[df_gb_ind['state'].str.contains('live')==False]
df_gb_ind = df_gb_ind[df_gb_ind['state'].str.contains('suspended')==False]
df_gb_ind.head()

# *I checked the statistics for successful vs failed startups*

df_gb_ind['state'].value_counts()

sns.pairplot(df_gb_ind)

sns.rugplot(df_gb_ind['usd_pledged_real'])

sns.countplot(x='state',data=df_gb_ind)

sns.kdeplot(df_gb_ind['usd_pledged_real'])

#histograms for each variable in dataset
df_gb_ind = df_gb_ind.hist(bins=10,figsize =(10,10))

# + [markdown] jupyter={"source_hidden": true} tags=[]
# ## France: Art
# -

# I chose art for France, because it has a lot of museums, and the history of the country with Napoleon made the country full of antique arts 

df_fr_ind = df_short[df_short['country'].str.contains('FR')]
df_fr_ind = df_fr_ind[df_fr_ind.main_category == 'Art']
df_fr_ind = df_fr_ind[df_fr_ind['state'].str.contains('canceled')==False]
df_fr_ind = df_fr_ind[df_fr_ind['state'].str.contains('live')==False]
df_fr_ind = df_fr_ind[df_fr_ind['state'].str.contains('suspended')==False]
df_fr_ind.head()

# *I checked the statistics for successful vs failed startups*

df_fr_ind['state'].value_counts()

sns.pairplot(df_fr_ind)

sns.rugplot(df_fr_ind['usd_pledged_real'])

sns.countplot(x='state',data=df_fr_ind)

sns.kdeplot(df_fr_ind['usd_pledged_real'])

# + tags=[]
#histograms for each variable in dataset
df_fr_ind = df_fr_ind.hist(bins=10,figsize =(10,10))

# + [markdown] jupyter={"source_hidden": true} tags=[]
# ## Italy: Fashion 
# -

# I chose Fashion filter for Italy since Italy is famous for its clothes brands

df_it_ind = df_short[df_short['country'].str.contains('IT')]
df_it_ind = df_it_ind[df_it_ind.main_category == 'Fashion']
df_it_ind = df_it_ind[df_it_ind['state'].str.contains('canceled')==False]
df_it_ind = df_it_ind[df_it_ind['state'].str.contains('live')==False]
df_it_ind = df_it_ind[df_it_ind['state'].str.contains('suspended')==False]
df_it_ind.head()

# *I checked the statistics for successful vs failed startups*

# + tags=[]
df_it_ind['state'].value_counts()
# -

sns.pairplot(df_it_ind)

sns.rugplot(df_it_ind['usd_pledged_real'])

sns.countplot(x='state',data=df_it_ind)

# ### Therefore, We can see, that a popular insstry of the country does not always mean that the project will be successful. Statistically, around 10% of the startups succeed, and in countries such as France, Great Britain, and the US the statistics showed a positive results; whereas, Italian fashion startups were on the average percentile of the success rate

StarcoderdataJupyterScriptsDedupFiltered