Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Pct_change in pandas

Shulou Source: shulou.com Published: 2022-06-01 02:59:37 09月22日 Update

This article mainly shows you "how to use Pct_change in pandas". The content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "how to use Pct_change in pandas".

Pct_change

Pct_change is a statistical function that represents the percentage difference between the current element and the previous element. The interval between the two elements can be adjusted.

For example, given three elements [2, 3, 6], calculate the percentage difference and get [NaN, 0.5, 1.0], increasing by 50% from the first element to the second element and by 100% from the second element to the third element.

Usage:

DataFrame.pct_change(periods=1, fill_method=‘pad’, limit=None, freq=None, **kwargs)

Parameter function:

periods: interval interval, i.e. step size

fill_method: method of handling null values

Calculate the growth rate for the value_1 column of df:

df.value_1.pct_change()

The above is "Pandas Pct_change how to use" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Tags: Element content article three interval percentage percentage learning help function function parameter growth rate method easy to understand more organization for example knowledge editing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn Shulou Tech Info Docker MariaDB