human
Pyhon - Best way to find the 1d center of mass in a binary numpy array
assistant
Here is some code to calculate the mean of the nonzero values' indices of dataframe `df`

np.flatnonzero(x).mean()

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.