Skip to content
Advertisement

Tag: mean

How to replace irrelevant data into mean values?

Let’s say I have 600,000 data points in column for age. In the data there are values 0 and -1, which is not relevant for age. How can I change both 0 and -1 values in my data to the column mean value using python? The code so far: Answer You can find the mean separatly and then use the

groupby with diff function

I have a groupby with a diff function, however I want to add an extra mean column for heart rate, how can I do this the best way? this is the code where should I add in the piece of code to calculate the average heart rate? output will be the amount of seconds in high power zone and then

calculate sum of squares with rows above

I have a dataset that looks like this: I want to iterate through each row and calculate a sum of squares value for each row above (only if the Type matches). I want to put this value in the X.sq column. So for example, in the first row, there’s nothing above. So only (-1.975767 x -1.975767). In the second row,

Pandas groupby datetime columns by periods

I have the following dataframe: I would like to get for each row (e.g a,b,c,d …) the mean vale between specific hours. The hours are between 9-15, and I want to groupby period, for example to calculate the mean value between 09:00:00 to 11:00:00, between 11- 12, between 13-15 (or any period I decide to). I was trying first to

Why is statistics.mean() so slow?

I compared the performance of the mean function of the statistics module with the simple sum(l)/len(l) method and found the mean function to be very slow for some reason. I used timeit with the two code snippets below to compare them, does anyone know what causes the massive difference in execution speed? I’m using Python 3.5. The code above executes

Advertisement