0

How can I calculate the average weight in python for two columns (x,y) data file, between 8<r< 9. in python

I have tried this put it dose not work with my

np.average(X,Y, weights=[8,9])

I have calculated the average weight which is 12.14, now I am trying to use this weight to calculate the average fro the X, Y values??
How can I do so ?

Edited by ALosh99

2
Contributors
2
Replies
23
Views
3 Weeks
Discussion Span
Last Post by vaishali_2
0

this what I have tried to do , but I am still missing somthing which I do not know what is it?

def weighted(x, cols, w="weights"):
             return pd.Series(np.average(x[cols], weights=x[w], axis=0), cols)

 g.apply(weighted, ["column1", "column2"])           
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.