def _dtype(self, c):
n = ':'.join(c)
if n in self.var_dtype:
return self.var_dtype[n]
# ranking in order is: float, int, short, char
elif any(self.var_dtype[col] == np.dtype(float) for col in c if col in self.var_dtype):
return np.dtype(float)
elif any(self.var_dtype[col] == np.dtype(int) for col in c if col in self.var_dtype):
return np.dtype(int)
elif any(self.var_dtype[col] == np.datetime64 for col in c if col in self.var_dtype):
return np.dtype(int)
elif any(self.var_dtype[col] == np.dtype('short') for col in c if col in self.var_dtype):
return np.dtype('short')
elif any(self.var_dtype[col] == np.dtype('byte') for col in c if col in self.var_dtype):
return np.dtype('byte')
elif any(self.var_dtype[col] == np.dtype(bool) for col in c if col in self.var_dtype):
return np.dtype(bool)
# default is float
return self._default_dtype
评论列表
文章目录