Descriptive Statistics#
statista.time_series.descriptive
#
Descriptive statistics for TimeSeries.
This module provides the Descriptive class which adds statistical summary
properties and methods to TimeSeries. It includes conventional moments
(mean, std, skewness, kurtosis), robust measures (MAD, IQR), and L-moments
for distribution identification.
Descriptive
#
Bases: _TimeSeriesStub
Descriptive statistical methods for TimeSeries.
Source code in src\statista\time_series\descriptive.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
stats
property
#
Basic statistical summary of the time series.
Delegates to pandas.DataFrame.describe(), returning count, mean,
standard deviation, min, quartiles, and max for each column.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: One column per series. Rows: count, mean, std, min, 25%, 50%, 75%, max. |
Examples:
- Load real hydrological data and inspect basic statistics:
>>> import numpy as np >>> from statista.time_series import TimeSeries >>> data = np.loadtxt("examples/data/time_series1.txt") >>> ts = TimeSeries(data) >>> s = ts.stats >>> s.index.tolist() ['count', 'mean', 'std', 'min', '25%', '50%', '75%', 'max'] >>> round(float(s.loc["mean", "Series1"]), 2) 16.93 - Multi-column data returns one column per series:
See Also
extended_stats: Adds CV, skewness, kurtosis, IQR, MAD, and extra percentiles. summary: Paper-ready table combining extended_stats and L-moment ratios.
extended_stats
property
#
Comprehensive statistical summary with 17 measures per column.
Extends stats with coefficient of variation (CV), skewness (bias-corrected),
excess kurtosis (bias-corrected), additional percentiles (5%, 10%, 90%, 95%),
interquartile range (IQR), and median absolute deviation (MAD). NaN values are
dropped per column before computation.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: One column per series. Rows: count, mean, std, cv, skewness, kurtosis, min, 5%, 10%, 25%, 50%, 75%, 90%, 95%, max, iqr, mad. |
Examples:
- Compute extended statistics for real hydrological data:
>>> import numpy as np >>> from statista.time_series import TimeSeries >>> data = np.loadtxt("examples/data/time_series1.txt") >>> ts = TimeSeries(data) >>> e = ts.extended_stats >>> e.index.tolist() ['count', 'mean', 'std', 'cv', 'skewness', 'kurtosis', 'min', '5%', '10%', '25%', '50%', '75%', '90%', '95%', 'max', 'iqr', 'mad'] >>> round(float(e.loc["cv", "Series1"]), 4) 0.0615 >>> round(float(e.loc["skewness", "Series1"]), 4) 0.9279 - Multi-column with named columns:
>>> import numpy as np >>> from statista.time_series import TimeSeries >>> np.random.seed(42) >>> data = np.column_stack([np.random.randn(100) * 10 + 50, ... np.random.randn(100) * 5 + 20]) >>> ts = TimeSeries(data, columns=["Flow", "Temp"]) >>> e = ts.extended_stats >>> round(float(e.loc["mean", "Flow"]), 2) 48.96 >>> round(float(e.loc["mean", "Temp"]), 2) 20.11 - NaN values are excluded from calculations:
See Also
stats: Basic 8-row summary via pandas describe(). l_moments: L-moment ratios for robust distribution identification. summary: Combined table of extended_stats + L-moment ratios.
l_moments(nmom=5)
#
Compute sample L-moments and L-moment ratios for each column.
L-moments (Hosking, 1990) are summary statistics computed from linear combinations of order statistics. They are more robust to outliers than conventional moments and better suited for small samples and heavy-tailed data. They are the standard tool for distribution identification in regional frequency analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nmom
|
int
|
Number of L-moments to compute. Must be >= 2. Default is 5. |
5
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: Rows: L1 (L-location = mean), L2 (L-scale), t (L-CV = L2/L1), t3 (L-skewness = L3/L2), t4 (L-kurtosis = L4/L2), and optionally t5 if nmom >= 5. One column per series. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If nmom < 2. |
Examples:
- Compute L-moments for real hydrological data:
>>> import numpy as np >>> from statista.time_series import TimeSeries >>> data = np.loadtxt("examples/data/time_series1.txt") >>> ts = TimeSeries(data) >>> lm = ts.l_moments(nmom=4) >>> lm.index.tolist() ['L1', 'L2', 't', 't3', 't4'] >>> round(float(lm.loc["L1", "Series1"]), 4) 16.9292 >>> round(float(lm.loc["t3", "Series1"]), 4) 0.4815 - L1 equals the sample mean:
- Symmetric data has L-skewness near zero:
References
Hosking, J.R.M. (1990). L-moments: Analysis and estimation of distributions using linear combinations of order statistics. Journal of the Royal Statistical Society, Series B, 52(1), 105-124.
See Also
extended_stats: Conventional moments (skewness, kurtosis) and percentiles. summary: Combined table of extended_stats + L-moment ratios.
Source code in src\statista\time_series\descriptive.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
summary()
#
Comprehensive summary table suitable for a research paper.
Combines extended_stats and l_moments into a single table with
13 rows per column. This produces the kind of "Table 1" that goes into
a paper's methods or study-area section.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: One column per series. Rows: count, mean, std, cv, skewness, kurtosis, min, max, iqr, mad, L-CV, L-skewness, L-kurtosis. |
Examples:
- Generate a paper-ready summary from real data:
>>> import numpy as np >>> from statista.time_series import TimeSeries >>> data = np.loadtxt("examples/data/time_series1.txt") >>> ts = TimeSeries(data) >>> sm = ts.summary() >>> sm.index.tolist() ['count', 'mean', 'std', 'cv', 'skewness', 'kurtosis', 'min', 'max', 'iqr', 'mad', 'L-CV', 'L-skewness', 'L-kurtosis'] >>> len(sm) 13 >>> round(float(sm.loc["L-skewness", "Series1"]), 4) 0.4815 - Multi-column summary for comparing stations:
>>> import numpy as np >>> from statista.time_series import TimeSeries >>> np.random.seed(42) >>> data = np.column_stack([np.random.randn(100) * 10 + 50, ... np.random.randn(100) * 5 + 20]) >>> ts = TimeSeries(data, columns=["Flow", "Temp"]) >>> sm = ts.summary() >>> sm.columns.tolist() ['Flow', 'Temp'] >>> round(float(sm.loc["mean", "Flow"]), 2) 48.96
See Also
extended_stats: The 17-row conventional statistics table. l_moments: L-moment ratios independently.