Repository: modin-project/modin

Issue:
Modin throws RayGetError when doing cumulative functions
### Describe the problem

Throws `RayGetError` when doing cumulative functions of nonnumeric dtypes

### Source code / logs
```
import modin.pandas as pd
data = {
        "col1": 1.0,
        "col2": np.datetime64("2011-06-15T00:00"),
        "col3": np.array([3] * 4, dtype="int32"),
        "col4": "foo",
        "col5": True,
}
modin_df = pd.DataFrame(data)
modin_df.cummax(axis=1)
```
Throws the following error:
```
RayGetError: Could not get objectid ObjectID(01000000f0cc325805f5c83895ed0532827d52de). It was created by remote function modin.data_management.partitioning.axis_partition.deploy_ray_axis_func which failed with:

Remote function modin.data_management.partitioning.axis_partition.deploy_ray_axis_func failed with:

Traceback (most recent call last):
  File "/Users/William/Documents/modin/modin/data_management/partitioning/axis_partition.py", line 188, in deploy_ray_axis_func
    result = func(dataframe, **kwargs)
  File "/Users/William/Documents/modin/modin/data_management/data_manager.py", line 158, in helper
    def helper(df, internal_indices=[]):
  File "/Users/William/Documents/modin/venv/lib/python3.6/site-packages/pandas/core/generic.py", line 9661, in cum_func
    result = accum_func(y, axis)
  File "/Users/William/Documents/modin/venv/lib/python3.6/site-packages/pandas/core/generic.py", line 8829, in <lambda>
    lambda y, axis: np.maximum.accumulate(y, axis), "max",
  File "pandas/_libs/tslibs/timestamps.pyx", line 170, in pandas._libs.tslibs.timestamps._Timestamp.__richcmp__
TypeError: Cannot compare type 'Timestamp' with type 'float'
```



Discussion:

Resolving patch:
diff --git a/modin/pandas/dataframe.py b/modin/pandas/dataframe.py
--- a/modin/pandas/dataframe.py
+++ b/modin/pandas/dataframe.py
@@ -1012,6 +1012,8 @@ def cummax(self, axis=None, skipna=True, *args, **kwargs):
             The cumulative maximum of the DataFrame.
         """
         axis = pandas.DataFrame()._get_axis_number(axis) if axis is not None else 0
+        if axis:
+            self._validate_dtypes()
         return DataFrame(
             data_manager=self._data_manager.cummax(axis=axis, skipna=skipna, **kwargs)
         )
@@ -1027,6 +1029,8 @@ def cummin(self, axis=None, skipna=True, *args, **kwargs):
             The cumulative minimum of the DataFrame.
         """
         axis = pandas.DataFrame()._get_axis_number(axis) if axis is not None else 0
+        if axis:
+            self._validate_dtypes()
         return DataFrame(
             data_manager=self._data_manager.cummin(axis=axis, skipna=skipna, **kwargs)
         )
@@ -1042,6 +1046,7 @@ def cumprod(self, axis=None, skipna=True, *args, **kwargs):
             The cumulative product of the DataFrame.
         """
         axis = pandas.DataFrame()._get_axis_number(axis) if axis is not None else 0
+        self._validate_dtypes(numeric_only=True)
         return DataFrame(
             data_manager=self._data_manager.cumprod(axis=axis, skipna=skipna, **kwargs)
         )
@@ -1057,6 +1062,7 @@ def cumsum(self, axis=None, skipna=True, *args, **kwargs):
             The cumulative sum of the DataFrame.
         """
         axis = pandas.DataFrame()._get_axis_number(axis) if axis is not None else 0
+        self._validate_dtypes(numeric_only=True)
         return DataFrame(
             data_manager=self._data_manager.cumsum(axis=axis, skipna=skipna, **kwargs)
         )
@@ -4628,3 +4634,14 @@ def _validate_other(self, other, axis):
                         "given {1}".format(len(self.columns), len(other))
                     )
         return other
+
+    def _validate_dtypes(self, numeric_only=False):
+        """Helper method to check that all the dtypes are the same"""
+        dtype = self.dtypes[0]
+        for t in self.dtypes:
+            if numeric_only and not is_numeric_dtype(t):
+                raise TypeError("{0} is not a numeric data type".format(t))
+            elif not numeric_only and t != dtype:
+                raise TypeError(
+                    "Cannot compare type '{0}' with type '{1}'".format(t, dtype)
+                )


Test patch: