ELSTE Data science

Class 2: Exploratory data analysis

Sébastien Biass

Earth Sciences

Stéphane Guerrier

Earth Sciences

Pharmaceutical Sciences

October 21, 2026

Today’s objectives

  • Last week: We learned how to handle data using Pandas
    • Load, access, query, filter, sort and operate on data
  • This week: You received / compiled / produced a new dataset
  • Review common tasks / method to get accustomed to the dataset
    • Understand its structure → what type of data does it contain
    • Explore it visually → plotting with dedicated libraries
    • Describe single variables → univariate analyses
    • Assess coupled behaviours of two variables → bivariate analyses
    • First attempt at modelling these behaviours → linear regressions

Sample vs population

The dataset

Case study

  • Campi Flegrei: Home to 1.5 million people
  • Caldera-forming eruptions
    • Campanian Ignimbrite (CI), ~39 ka ago
    • Neapolitan Yellow Tuff (NYT), ~15 ka ago

Dataset

Tephrostratigraphy and glass compositions of post-15 kyr Campi Flegrei eruptions

  • Smith et al. (2011)
  • Major and trace elements

Loading the dataset

  • Import pandas
  • Load an excel file using pandas
  • Specify which sheet to read from using the sheet_name argument
    • Supp_majors → df_majors
    • Supp_traces → df_traces

# Load Pandas
import pandas as pd # Import pandas

# Import the dataset specifying which Excel sheet name to load the data from
df_majors = pd.read_csv('https://raw.githubusercontent.com/ELSTE-Master/Data-Science/main/Data/Smith_glass_post_NYT_data_majors.csv')
df_traces = pd.read_csv('https://raw.githubusercontent.com/ELSTE-Master/Data-Science/main/Data/Smith_glass_post_NYT_data_traces.csv')

Inspecting the dataset

df_traces.head(5)
Analysis no. Strat. Pos. Eruption controlcode Sample Epoch Crater size Date of analysis Si/bulk cps SiO2* (EMP) ... Ho Er Tm Yb Lu Hf Ta Pb Th U
0 1915 63 Astroni 7 1 79 three-b 20 100210am 20.21 59.27 ... 1.11 3.26 0.47 2.80 0.43 7.84 2.96 60.93 35.02 9.20
1 1916 63 Astroni 7 1 79 three-b 20 100210am 11.92 59.27 ... 1.08 2.27 0.46 3.14 0.46 7.33 3.52 59.89 34.46 10.46
2 1917 63 Astroni 7 1 79 three-b 20 100210am 17.06 59.27 ... 1.25 3.69 0.61 3.51 0.63 8.43 3.05 49.87 29.22 8.73
3 1918 63 Astroni 7 1 79 three-b 20 100210am 24.52 59.27 ... 1.24 3.72 0.46 3.04 0.44 8.95 3.08 59.59 30.71 9.79
4 1919 63 Astroni 7 1 79 three-b 20 100210am 14.35 59.27 ... 1.08 2.68 0.46 2.79 0.41 7.24 2.67 60.70 32.13 9.01

5 rows × 37 columns

df_traces.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 370 entries, 0 to 369
Data columns (total 37 columns):
 #   Column            Non-Null Count  Dtype  
---  ------            --------------  -----  
 0   Analysis no.      370 non-null    int64  
 1   Strat. Pos.       370 non-null    int64  
 2   Eruption          370 non-null    object 
 3   controlcode       370 non-null    int64  
 4   Sample            370 non-null    object 
 5   Epoch             370 non-null    object 
 6   Crater size       370 non-null    int64  
 7   Date of analysis  370 non-null    object 
 8   Si/bulk cps       370 non-null    float64
 9   SiO2* (EMP)       370 non-null    float64
 10  Sc                370 non-null    float64
 11  Rb                370 non-null    int64  
 12  Sr                369 non-null    float64
 13  Y                 370 non-null    float64
 14  Zr                370 non-null    int64  
 15  Nb                370 non-null    float64
 16  Cs                370 non-null    float64
 17  Ba                370 non-null    float64
 18  La                370 non-null    float64
 19  Ce                370 non-null    float64
 20  Pr                370 non-null    float64
 21  Nd                370 non-null    float64
 22  Sm                370 non-null    float64
 23  Eu                370 non-null    float64
 24  Gd                370 non-null    float64
 25  Tb                370 non-null    float64
 26  Dy                370 non-null    float64
 27  Ho                370 non-null    float64
 28  Er                370 non-null    float64
 29  Tm                370 non-null    float64
 30  Yb                370 non-null    float64
 31  Lu                369 non-null    float64
 32  Hf                370 non-null    float64
 33  Ta                370 non-null    float64
 34  Pb                368 non-null    float64
 35  Th                370 non-null    float64
 36  U                 370 non-null    float64
dtypes: float64(27), int64(6), object(4)
memory usage: 107.1+ KB

Types of data

Basic types of data

  • int: Integer numbers → 0, 1, 2, …
  • float: Decimal numbers → 1.1, 1.2, 1.3, …
  • object: Strings → “Campi Flegrei”

A note on Bytes

  • int and float numbers are followed by 8, 16, 32 or 64 → Byte → control how much memory a variable uses
  • A Bit is a binary digit → 0/1 → smallest possible unit of data
  • int8 can store \(2^8\) digits = 256
  • int16 can store \(2^16\) digits = 65’563

Families of data

Numerical data


  • Represent quantities or measurable values
  • Quantitative
    • Discrete: Earthquake counts
    • Continuous: Temperature
  • Stored as numerical values
  • Operations → arithmetic

Categorical data


  • Represent categories or groups of data
  • Qualitative / semi-quantitative
    • Nominal: No order → Landslide type
    • Ordinal: Order → rank
  • Stored as strings or integer
  • Operations → counting, grouping

Families of data - cheat sheet

Feature Categorical Data Numerical Data
Definition Categories or groups of data Quantities or measurable values
Nature Qualitative (describes qualities) Quantitative (describes amounts or measurements)
Data Type Non-numeric (often text or labels) Numeric (numbers only)
Examples Eruption type Element concentration
Possible Operations Counting, grouping, mode Arithmetic operations
Measurement Scale Nominal or Ordinal Interval or Ratio
Visualization Tools Bar chart, Pie chart Histogram, Box plot, Scatter plot
Subtypes Nominal: Categories with no order (e.g., color); Ordinal: Categories with order (e.g., rank) Discrete: Countable numbers (e.g., number of earthquakes); Continuous: Measurable values (e.g., temperature)
Examples of Statistical Summary Frequency, mode Mean, median, standard deviation
Storage Format Strings or labels Integers or floats

Today

Exploratory data analysis

Can fractional crystallisation explain the chemical variability of Campi Flegrei glasses, or do we need magma mixing?

  • Univariate: Are element concentrations narrowly distributed, broadly spread or multimodal?
  • Bivariate: Are relationships such as Sr–Zr consistent with Sr removal by feldspar crystallisation while Zr becomes enriched in the residual melt?
  • Interpretation: Can one differentiation process explain the observations, or are multiple magma components needed?
    • Correlation ≠ mechanistic explanation
  • Sample vs population: Do the analysed glasses capture the compositional variability within each eruption?

Objectives

  1. Understand data structure
    • Type and completeness of dataset
  2. Basics of plotting with matplotlib and seaborn
  3. Univariate statistics
    • Position, spread, shape
    • Quantification + visualisation
  4. Bivariate statistics
    • Covariance & Correlation
    • Intro to regression + residual analysis

Your turn!