Skip to content

Staffelter Hof Winery is Germany's oldest business, established in 862 under the Carolingian dynasty. It has continued to serve customers through dramatic changes in Europe, such as the Holy Roman Empire, the Ottoman Empire, and both world wars. What characteristics enable a business to stand the test of time?

To help answer this question, BusinessFinancing.co.uk researched the oldest company still in business in almost every country and compiled the results into several CSV files. This dataset has been cleaned.

Having useful information in different files is a common problem. While it's better to keep different types of data separate for data storage, you'll want all the data in one place for analysis. You'll use joining and data manipulation to work with this data and better understand the world's oldest businesses.

The Data

data/businesses.csv and data/new_businesses.csv

ColumnDescription
businessName of the business (varchar)
year_foundedYear the business was founded (int)
category_codeCode for the business category (varchar)
country_codeISO 3166-1 three-letter country code (char)

data/countries.csv

ColumnDescription
country_codeISO 3166-1 three-letter country code (varchar)
countryName of the country (varchar)
continentName of the continent the country exists in (varchar)

data/categories.csv

ColumnDescription
category_codeCode for the business category (varchar)
categoryDescription of the business category (varchar)
# Import necessary libraries
import pandas as pd

# Load the data
businesses = pd.read_csv("data/businesses.csv")
new_businesses = pd.read_csv("data/new_businesses.csv")
countries = pd.read_csv("data/countries.csv")
categories = pd.read_csv("data/categories.csv")

Question 1

Oldest by Continent

#For question 1, we must get the continent for each business.
df_by_continent = businesses.merge(countries,on='country_code')
df_first_year_by_continent = df_by_continent.groupby('continent')['year_founded'].min()
oldest_business_continent = df_by_continent.merge(df_first_year_by_continent,on=['year_founded','continent'])[['continent','country','business','year_founded']]

oldest_business_continent

Question 2

Find the number of countries, per continent, which have no business information.

Include New Businesses in this analysis.

all_businesses = pd.concat([businesses,new_businesses])
all_businesses
#Get geographic location for all business.  Create indicator column.
all_businesses_data = (countries
                       .merge(all_businesses,how='outer',on='country_code',indicator=True
                                )
                 ).drop_duplicates()


all_businesses_data
#Using the indicator column, we find rows with country data but no business data.
count_missing = all_businesses_data[all_businesses_data['_merge']!='both'][['continent','country']].drop_duplicates().groupby('continent').agg(count_missing=('country','count'))

                 
count_missing

Does New Businesses have any affect on this count?

businesses_data_excluding_nb = (countries
                       .merge(businesses,how='outer',on='country_code',indicator=True
                                )
                 ).drop_duplicates()


businesses_data_excluding_nb
#Using the indicator column, we find rows with country data but no business data.
count_missing_no_nb = businesses_data_excluding_nb[businesses_data_excluding_nb['_merge']!='both'][['continent','country']].drop_duplicates().groupby('continent').agg(count_missing_no_nb=('country','count'))

                 
count_missing_no_nb
#compare
df_effect_of_nb = count_missing.merge(count_missing_no_nb,how="left",on="continent")

df_effect_of_nb[df_effect_of_nb["count_missing_no_nb"]!=df_effect_of_nb["count_missing"]]

Yes. We get businesses for NA and Oceania that were missing in businesses