Implementation of Maximum Drawdown in python working directly with returns

I have a strategy on a stock (such as Buy and Hold) on which I have to calculate the maximum drawdown. The problem is that I'm working on returns expressed in percentages, so I do not have the time series of prices but the one of returns obtained at each step. So I wrote this code:

def MDD(returns):
rend_cum=returns.cumsum()
rend_max=pd.Series(rend_cum).cummax()
drawdown=rend_cum-rend_max
MDD=max(abs(drawdown))

return(MDD)


Is it correct?

You are missing a few things. The function below assumes that returns is either a pandas series or a column of a pandas dataframe. Try this:
def MDD(returns):