pyMannKendall is a Python package providing a comprehensive suite of non-parametric Mann-Kendall family of trend tests. It includes 11 different Mann-Kendall tests and 2 Sen's slope estimator functions, making it suitable for analyzing monotonic trends in time series data without assumptions about data distribution. The library is actively maintained, with version 1.4.3 released in early 2023, and receives regular updates to address bugs and introduce new features.
pip install pymannkendallVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to perform a basic Mann-Kendall trend test on a NumPy array. The `original_test` function returns a named tuple with various statistics including the trend ('increasing', 'decreasing', or 'no trend'), p-value, Kendall Tau, and Sen's slope.
For autocorrelated data, use modified Mann-Kendall tests available in the package, such as `hamed_rao_modification_test`, `yue_wang_modification_test`, or `pre_whitening_modification_test` that account for serial correlation.
For data exhibiting seasonal patterns, utilize the `seasonal_test` or `seasonal_sens_slope` functions, which are designed to handle seasonal effects by considering each seasonal period separately.
Ensure your input data is in a suitable numerical format (e.g., NumPy array or Pandas Series of float/int). Always update to the latest version of `pymannkendall` to benefit from bug fixes related to data handling.
It is recommended to have at least 10 observations for more reliable test results.
pip install pymannkendall
Ensure the input data series has variability (not all values are the same). Pre-process data to remove constant segments or check for data quality issues.
Ensure that both input series (e.g., response parameter and independent parameter) have the exact same length before passing them to the function.
Ensure `pymannkendall` is imported, typically as `mk`, and call the function using `mk.original_test(your_data_list)`.