text_html_output_1.png text_plain_output_1.png
import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

comp_df = pd.read_csv('../input/free-7-million-company-dataset/companies_sorted.csv')

#Check of dataset
comp_df.head()
comp_df.tail()

comp_df.shape

comp_df.info()
comp_df.describe()

#change name of columns and make it with fist upper letter.
comp_df.rename(columns={'year founded':'year_founded','size range':'size_range','linkedin url':'linkedin_url','current employee estimate':'current_employee_estimate','total employee estimate':'total_employee_estimate'}, inplace=True)
comp_df.columns=comp_df.columns.str.capitalize()
print(comp_df.columns)
comp_df['Country']=comp_df.Country.str.title()
comp_df.head()

continent_df = pd.read_csv('../input/continent/country_continent.csv', delimiter=';', encoding='ISO-8859-1')
continent_1 = continent_df[['Continent', 'Country']]

comp_nonan_df = comp_df.dropna(axis=0, subset=['Country'])
comp_nonan_df.shape
marge_df = pd.merge(comp_nonan_df, continent_1, on='Country', how='left')
marge_df

contin_null = marge_df[['Continent', 'Country']]
contin_null
df_null = contin_null.loc[contin_null['Continent'].isnull()]
df_null
df_null['Country'].unique()
dict_null = [{'United States': 'North America', 'United Kingdom': 'Europe', 'Czechia': 'Europe', 'South Korea': 'Asia', 'Taiwan': 'Asia', 'Venezuela': 'South America', 'Hong Kong': 'Asia', 'Russia': 'Europe', 'Iran': 'Asia', 'Vietnam': 'Asia', 'Palestine': 'Asia', 'Trinidad And Tobago': 'North America', 'Macau': 'Asia', 'Syria': 'Asia', 'Tanzania': 'Africa', 'Isle Of Man': 'Europe', 'Brunei': 'Asia', 'Micronesia': 'Oceania', 'Côte D’Ivoire': 'Africa', 'Macedonia': 'Europe', 'Bolivia': 'South America', 'Moldova': 'Europe', 'Bosnia And Herzegovina': 'Europe', 'Democratic Republic Of The Congo': 'Africa', 'Netherlands Antilles': 'Europe', 'Laos': 'Asia', 'Saint Vincent And The Grenadines': 'North America', 'Faroe Islands': 'Europe', 'Saint Kitts And Nevis': 'North America', 'Kosovo': 'Europe', 'Cape Verde': 'Africa', 'Svalbard And Jan Mayen': 'Europe', 'Turks And Caicos Islands': 'North America', 'São Tomé And Príncipe': 'Africa', 'Caribbean Netherlands': 'North America', 'Sint Maarten': 'North America', 'North Korea': 'Asia', 'Antigua And Barbuda': 'North America', 'Republic Of The Congo': 'Africa', 'Saint Martin': 'North America', 'U.S. Virgin Islands': 'North America', 'Saint Pierre And Miquelon': 'North America', 'Saint Barthélemy': 'North America'}]
df_5 = pd.DataFrame(dict_null).transpose()
df_5 = df_5.reset_index()
df_5.columns = ['Country', 'Continent']
continent_2 = pd.concat([continent_1, df_5], sort=True)
fi_df = pd.merge(comp_nonan_df, continent_2, on='Country', how='left')
fi_df['Continent'].isnull().any()
fi_df.drop(['Unnamed: 0', 'Domain', 'Locality', 'Linkedin_url'], axis=1, inplace=True)

Europa_df = fi_df[fi_df['Continent'] == 'Europe']

pkb_df = pd.read_csv('../input/gdpset/GDP.csv', delimiter=';')
pkb_df = pkb_df.loc[:, ['Country', 'GDP_2016', 'GDP_2017', 'GDP_PC_2018']]
pkb_sorted = pkb_df.sort_values(['GDP_2017'], ascending=[True])
pkb_sorted.set_index('Country')

pkb_eu = pd.merge(Europa_df, pkb_df, on='Country', how='left')
pkb_eu.info()
pkb_eu_cl = pkb_eu.dropna(axis=0, subset=['GDP_2017'])
pkb_eu_cl['GDP_2017'] = pkb_eu_cl['GDP_2017'].astype('int64')
pkb_eu_cl['GDP_2016'] = pkb_eu_cl['GDP_2016'].astype('int64')
pkb_eu_cl['GDP_PC_2018'] = pkb_eu_cl['GDP_PC_2018'].astype('int64')
pkb_eu_cl = pkb_eu_cl.loc[:, ['Country', 'Total_employee_estimate', 'Current_employee_estimate', 'GDP_2017', 'GDP_2016', 'GDP_PC_2018']]
pkb_eu_cl.info()
pkb_eu_cl.head()