| 1220 | |
| 1221 | |
| 1222 | class Mean(Reduction): |
| 1223 | _parameters = ["frame", "skipna", "numeric_only", "split_every", "axis"] |
| 1224 | _defaults = {"skipna": True, "numeric_only": False, "split_every": False, "axis": 0} |
| 1225 | |
| 1226 | @functools.cached_property |
| 1227 | def _meta(self): |
| 1228 | return make_meta( |
| 1229 | meta_nonempty(self.frame._meta).mean( |
| 1230 | skipna=self.skipna, numeric_only=self.numeric_only, axis=self.axis |
| 1231 | ) |
| 1232 | ) |
| 1233 | |
| 1234 | def _lower(self): |
| 1235 | s = self.frame.sum( |
| 1236 | skipna=self.skipna, |
| 1237 | numeric_only=self.numeric_only, |
| 1238 | split_every=self.split_every, |
| 1239 | ) |
| 1240 | c = self.frame.count( |
| 1241 | split_every=self.split_every, numeric_only=self.numeric_only |
| 1242 | ) |
| 1243 | if self.axis is None and s.ndim == 1: |
| 1244 | return s.sum() / c.sum() |
| 1245 | else: |
| 1246 | return MeanAggregate(s, c) |
| 1247 | |
| 1248 | |
| 1249 | class MeanAggregate(Blockwise): |