Pandas custom function



Can anyone help me out in writing pandas custom functions? Every-time i fall in the confusion loop in accessing and deriving specific row and col values as custom results, i want to execute col means without using slicing no user defined functions like numpy(np.mean) and i need only parameter to pass is dataset ‘df’ to custom function

Below is my dataset please give me code logic in getting col means.

df = pd.DataFrame({"A": [10,20,30], "B": [20, 30, 10]})
def col_men(df):
means=[0 for i in range(df.shape[1])]
for k in range(df.shape[1]):
    col_values=[row[k] for row in df]
return means



In order to get mean for each column, you can use

for i in range (0,n) #range will be the number of rows you have
mean = sum/n


thank you