Skip to content
0

1️⃣ Part 1 (Python) - Dinosaur data 🦕

📖 Background

You're applying for a summer internship at a national museum for natural history. The museum recently created a database containing all dinosaur records of past field campaigns. Your job is to dive into the fossil records to find some interesting insights, and advise the museum on the quality of the data.

💾 The data

You have access to a real dataset containing dinosaur records from the Paleobiology Database (source):

Column nameDescription
occurence_noThe original occurrence number from the Paleobiology Database.
nameThe accepted name of the dinosaur (usually the genus name, or the name of the footprint/egg fossil).
dietThe main diet (omnivorous, carnivorous, herbivorous).
typeThe dinosaur type (small theropod, large theropod, sauropod, ornithopod, ceratopsian, armored dinosaur).
length_mThe maximum length, from head to tail, in meters.
max_maThe age in which the first fossil records of the dinosaur where found, in million years.
min_maThe age in which the last fossil records of the dinosaur where found, in million years.
regionThe current region where the fossil record was found.
lngThe longitude where the fossil record was found.
latThe latitude where the fossil record was found.
classThe taxonomical class of the dinosaur (Saurischia or Ornithischia).
familyThe taxonomical family of the dinosaur (if known).

The data was enriched with data from Wikipedia.

💪 Challenge I

Help your colleagues at the museum to gain insights on the fossil record data. Include:

  1. How many different dinosaur names are present in the data?
  2. Which was the largest dinosaur? What about missing data in the dataset?
  3. What dinosaur type has the most occurrences in this dataset? Create a visualization (table, bar chart, or equivalent) to display the number of dinosaurs per type. Use the AI assistant to tweak your visualization (colors, labels, title...).
  4. Did dinosaurs get bigger over time? Show the relation between the dinosaur length and their age to illustrate this.
  5. Use the AI assitant to create an interactive map showing each record.
  6. Any other insights you found during your analysis?
# Import the pandas and numpy packages
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Load the data
dinos = pd.read_csv('data/dinosaurs.csv')

The first 20 rows of the dataset

# The first 20 rows of the dataset
dinos.head(20)

Technical information about the dataset, such as the number of rows, columns, and data types

dinos.info()

Statistical summary of the dataset including mean, median, maximum, and minimum values of numeric columns

dinos.describe()

Checking null values and percentage of the dataset

dinos.isnull().sum()
dinos.isnull().sum()/len(dinos)*100

Imputation of null values in categorical columns

dinos_diet_mode = dinos['diet'].mode()[0]
dinos_type_mode = dinos['type'].mode()[0]
dinos_family_mode = dinos['family'].mode()[0]
dinos_region_mode = dinos['region'].mode()[0]

dinos['diet'] = dinos['diet'].fillna(dinos_diet_mode)
dinos['type'] = dinos['type'].fillna(dinos_type_mode)
dinos['family'] = dinos['family'].fillna(dinos_family_mode)
dinos['region'] = dinos['region'].fillna(dinos_region_mode)