Replace this for loop with a pandas vector operation
Try using list comprehension:
df_means = [np.diff(x)[0] for x in [df_common.sample(1000, replace = True).groupby([&quot;doggo&quot;]).retweet_count.mean().values.tolist() for _ in range(10000)]