@8500003639 wrote:
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] means[k]=sum(col_values)/float(len(df)) return means
Posts: 3
Participants: 2