trading view pine to python

Job ID: 32880126

Budget: $10 – $30 USD

I have a code in Pine:

float ph = pivothigh(2, 2)
float pl = pivotlow(2, 2)

// calculate the Center line using pivot points
var float center = na
float lastpp = ph ? ph : pl ? pl : na
if lastpp
if na(center)
center := lastpp
else
center := (center * 2 + lastpp) / 3

I need to transfer it to python code using pandas dataframe.
Related categories: Python Pine Script