简体   繁体   中英

How to apply a complex formula using Pandas in Python?

I need to apply a specially designed moving average filter on a traffic dataset (NGSim). This process is very tedious in Excel not only because dataset is very large but also because the formula has to look into columns for getting some values and sum them up. I was wondering if there are any examples like this or any other complicated formulas used in Pandas, Python. Kindly provide any example resources.

You are probably looking for rolling_apply . This is an example from the documentation:

mad = lambda x: np.fabs(x - x.mean()).mean()
rolling_apply(ts, 60, mad).plot(style='k')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM