Percentile/Quantile Analysis

Calculate and visualize percentiles 0-100 for time series data.

Demonstrates percentile analysis across the full 0-100 range for air temperature data, showing the distribution from minimum to maximum values with detailed statistics.

Best for: Understanding data distribution quantiles and percentile values

Load data

import diive as dv

df = dv.load_exampledata_parquet()
  > Loaded .parquet file
/home/docs/checkouts/diive/checkouts/latest/diive/configs/exampledata/exampledat
a_PARQUET_CH-DAV_FP2022.5_2013-2022_ID20230206154316_30MIN.parquet (0.080
seconds).

Calculate percentiles 0-100

# Calculate percentiles 0-100 for air temperature
percentiles_df = dv.analysis.percentiles101(series=df['Tair_f'], showplot=True, verbose=True)
Percentile values: Tair_f
Showing some percentiles for Tair_f:
     PERCENTILE    VALUE
0             0 -23.0960
1             1 -11.4902
5             5  -7.2570
16           16  -2.9670
25           25  -0.8000
50           50   4.6000
75           75  10.0670
84           84  12.3330
95           95  17.4830
99           99  22.0670
100         100  28.7130

Display full results

print("\nAll percentiles (0-100):")
print(percentiles_df)
All percentiles (0-100):
     PERCENTILE     VALUE
0             0 -23.09600
1             1 -11.49020
2             2  -9.94920
3             3  -8.78045
4             4  -7.90000
..          ...       ...
96           96  18.28400
97           97  19.19360
98           98  20.34730
99           99  22.06700
100         100  28.71300

[101 rows x 2 columns]

Summary statistics

print(f"\nSummary of Tair_f:")
print(f"  0th percentile (min):   {percentiles_df.iloc[0]['VALUE']:.2f} C")
print(f"  25th percentile:        {percentiles_df[percentiles_df['PERCENTILE'] == 25]['VALUE'].values[0]:.2f} C")
print(f"  50th percentile (median): {percentiles_df[percentiles_df['PERCENTILE'] == 50]['VALUE'].values[0]:.2f} C")
print(f"  75th percentile:        {percentiles_df[percentiles_df['PERCENTILE'] == 75]['VALUE'].values[0]:.2f} C")
print(f"  100th percentile (max): {percentiles_df.iloc[-1]['VALUE']:.2f} C")
Summary of Tair_f:
  0th percentile (min):   -23.10 C
  25th percentile:        -0.80 C
  50th percentile (median): 4.60 C
  75th percentile:        10.07 C
  100th percentile (max): 28.71 C

Total running time of the script: (0 minutes 0.438 seconds)

Gallery generated by Sphinx-Gallery