{"id":5402,"library":"pymannkendall","title":"pyMannKendall","description":"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.","status":"active","version":"1.4.3","language":"en","source_language":"en","source_url":"https://github.com/mmhs013/pymannkendall","tags":["statistical-analysis","time-series","non-parametric","trend-detection","mann-kendall","sen-slope","hydrology","climatology"],"install":[{"cmd":"pip install pymannkendall","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Numerical operations and array handling.","package":"numpy","optional":false},{"reason":"Scientific computing functions, likely for statistical calculations.","package":"scipy","optional":false}],"imports":[{"note":"Standard convention for importing the library, often aliased as 'mk'.","symbol":"pymannkendall","correct":"import pymannkendall as mk"},{"note":"Call directly on the aliased 'mk' object after import.","wrong":"pymannkendall.original_test(data)","symbol":"original_test","correct":"mk.original_test(data)"}],"quickstart":{"code":"import numpy as np\nimport pymannkendall as mk\n\n# Sample time series data\ndata = np.array([1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5])\n\n# Perform the original Mann-Kendall trend test\nresult = mk.original_test(data)\n\nprint(f\"Trend: {result.trend}\")\nprint(f\"P-value: {result.p}\")\nprint(f\"Kendall Tau: {result.Tau}\")\nprint(f\"Slope: {result.slope}\")\n# Output will indicate if a trend is present, its p-value, Tau, and Sen's slope.","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"The original Mann-Kendall test assumes serially independent data. Applying it to autocorrelated time series can lead to an inflated Type I error rate (i.e., detecting a trend where none exists due to correlated noise), resulting in misinterpretation of p-values.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"The original Mann-Kendall test does not account for seasonality in time series data. Applying it directly to seasonal data can lead to erroneous trend detection or misinterpretation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Recent versions (v1.4.2, v1.4.3) have addressed bugs related to type data conversion and integer type data arrays. While fixed, this indicates potential sensitivity to input data types or formats in older versions or edge cases.","severity":"gotcha","affected_versions":"<=1.4.1"},{"fix":"It is recommended to have at least 10 observations for more reliable test results.","message":"Reliability of the Mann-Kendall test statistics decreases with very small sample sizes (e.g., 3 or 4 observations).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}