constraints.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:tdda 作者: tdda 项目源码 文件源码
def pandas_tdda_type(x):
     dt = getattr(x, 'dtype', None)
     if type(x) == str or dt == np.dtype('O'):
         return 'string'
     dts = str(dt)
     if type(x) == bool or 'bool' in dts:
         return 'bool'
     if type(x) in (int, long) or 'int' in dts:
         return 'int'
     if type(x) == float or 'float' in dts:
         return 'real'
     if (type(x) == datetime.datetime or 'datetime' in dts
                 or type(x) == pandas_Timestamp):
         return 'date'
     if x is None or (not isinstance(x, pd.core.series.Series)
                      and pd.isnull(x)):
         return 'null'
     # Everything else is other, for now, including compound types,
     # unicode in Python2, bytes in Python3 etc.
     return 'other'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号