There are no NaN in the pandas dataframe, and when I look at each group of the groupby, they only have the Int64Index, and none of the rest of the non-groupby columns. I am baffled.
What am I missing?
Here is a reproducible code:
df = pd.DataFrame({
"a": np.random.rand(1000),
"b": np.random.rand(1000),
"c": np.random.rand(1000)
})
ranges = np.linspace(0, 1, 100)
df["a_bin"] = pd.cut(df.a, ranges)
df["b_bin"] = pd.cut(df.b, ranges)
print(df.groupby(["a_bin", "b_bin"]).c.mean())
and here is the result:
a_bin b_bin
(0.0, 0.0101] (0.0, 0.0101] NaN
(0.0101, 0.0202] NaN
(0.0202, 0.0303] NaN
(0.0303, 0.0404] NaN
(0.0404, 0.0505] NaN
..
(0.99, 1.0] (0.949, 0.96] NaN
(0.96, 0.97] NaN
(0.97, 0.98] NaN
(0.98, 0.99] NaN
(0.99, 1.0] NaN
Name: c, Length: 9801, dtype: float64
My pandas version is: 1.0.1