Exemplo n.º 1
0
 def test_as_json_table_type_categorical_data(self):
     self.assertEqual(as_json_table_type(pd.Categorical(['a'])), 'any')
     self.assertEqual(as_json_table_type(pd.Categorical([1])), 'any')
     self.assertEqual(as_json_table_type(
         pd.Series(pd.Categorical([1]))), 'any')
     self.assertEqual(as_json_table_type(pd.CategoricalIndex([1])), 'any')
     self.assertEqual(as_json_table_type(pd.Categorical([1])), 'any')
Exemplo n.º 2
0
 def test_as_json_table_type_categorical_data(self):
     self.assertEqual(as_json_table_type(pd.Categorical(['a'])), 'any')
     self.assertEqual(as_json_table_type(pd.Categorical([1])), 'any')
     self.assertEqual(as_json_table_type(
         pd.Series(pd.Categorical([1]))), 'any')
     self.assertEqual(as_json_table_type(pd.CategoricalIndex([1])), 'any')
     self.assertEqual(as_json_table_type(pd.Categorical([1])), 'any')
Exemplo n.º 3
0
 def test_as_json_table_type_float_data(self):
     float_data = [1., 2., 3.]
     float_types = [np.float, np.float16, np.float32, np.float64]
     for t in float_types:
         self.assertEqual(as_json_table_type(np.array(float_data,
                                                      dtype=t)),
                          'number')
Exemplo n.º 4
0
 def test_as_json_table_type_float_data(self):
     float_data = [1., 2., 3.]
     float_types = [np.float, np.float16, np.float32, np.float64]
     for t in float_types:
         self.assertEqual(as_json_table_type(np.array(float_data,
                                                      dtype=t)),
                          'number')
Exemplo n.º 5
0
 def test_as_json_table_type_date_data(self):
     date_data = [pd.to_datetime(['2016']),
                  pd.to_datetime(['2016'], utc=True),
                  pd.Series(pd.to_datetime(['2016'])),
                  pd.Series(pd.to_datetime(['2016'], utc=True)),
                  pd.period_range('2016', freq='A', periods=3)]
     for arr in date_data:
         self.assertEqual(as_json_table_type(arr), 'datetime')
Exemplo n.º 6
0
 def test_as_json_table_type_date_data(self):
     date_data = [pd.to_datetime(['2016']),
                  pd.to_datetime(['2016'], utc=True),
                  pd.Series(pd.to_datetime(['2016'])),
                  pd.Series(pd.to_datetime(['2016'], utc=True)),
                  pd.period_range('2016', freq='A', periods=3)]
     for arr in date_data:
         self.assertEqual(as_json_table_type(arr), 'datetime')
Exemplo n.º 7
0
 def test_as_json_table_type_date_dtypes(self):
     # TODO: datedate.date? datetime.time?
     dates = [
         np.datetime64,
         np.dtype("<M8[ns]"),
         PeriodDtype(),
         DatetimeTZDtype('ns', 'US/Central')
     ]
     for t in dates:
         self.assertEqual(as_json_table_type(t), 'datetime')
Exemplo n.º 8
0
 def test_as_json_table_type_categorical_data(self, cat_data):
     assert as_json_table_type(cat_data) == 'any'
Exemplo n.º 9
0
 def test_as_json_table_type_date_data(self, date_data):
     assert as_json_table_type(date_data) == 'datetime'
Exemplo n.º 10
0
 def test_as_json_table_type_float_data(self, float_type):
     float_data = [1., 2., 3.]
     assert as_json_table_type(np.array(float_data,
                                        dtype=float_type)) == 'number'
Exemplo n.º 11
0
 def test_as_json_table_type_timedelta_dtypes(self):
     durations = [np.timedelta64, np.dtype("<m8[ns]")]
     for t in durations:
         assert as_json_table_type(t) == 'duration'
Exemplo n.º 12
0
 def test_as_json_table_type_string_dtypes(self):
     strings = [object]  # TODO
     for t in strings:
         self.assertEqual(as_json_table_type(t), 'string')
Exemplo n.º 13
0
 def test_as_json_table_type_string_data(self):
     strings = [pd.Series(['a', 'b']), pd.Index(['a', 'b'])]
     for t in strings:
         self.assertEqual(as_json_table_type(t), 'string')
Exemplo n.º 14
0
 def test_as_json_table_type_string_dtypes(self, str_dtype):
     assert as_json_table_type(str_dtype) == 'string'
Exemplo n.º 15
0
 def test_as_json_table_type_categorical_dtypes(self):
     self.assertEqual(as_json_table_type(pd.Categorical), 'any')
     self.assertEqual(as_json_table_type(CategoricalDtype()), 'any')
Exemplo n.º 16
0
 def test_as_json_table_type_string_dtypes(self):
     strings = [object]  # TODO
     for t in strings:
         self.assertEqual(as_json_table_type(t), 'string')
Exemplo n.º 17
0
 def test_as_json_table_type_timedelta_dtypes(self):
     durations = [np.timedelta64, np.dtype("<m8[ns]")]
     for t in durations:
         self.assertEqual(as_json_table_type(t), 'duration')
Exemplo n.º 18
0
 def test_as_json_table_type_date_dtypes(self):
     # TODO: datedate.date? datetime.time?
     dates = [np.datetime64, np.dtype("<M8[ns]"), PeriodDtype(),
              DatetimeTZDtype('ns', 'US/Central')]
     for t in dates:
         self.assertEqual(as_json_table_type(t), 'datetime')
Exemplo n.º 19
0
 def test_as_json_table_type_bool_dtypes(self):
     bools = [bool, np.bool]
     for t in bools:
         self.assertEqual(as_json_table_type(t), 'boolean')
Exemplo n.º 20
0
 def test_as_json_table_type_float_dtypes(self):
     floats = [np.float, np.float16, np.float32, np.float64]
     for t in floats:
         self.assertEqual(as_json_table_type(t), 'number')
Exemplo n.º 21
0
 def test_as_json_table_type_int_dtypes(self):
     integers = [np.int, np.int16, np.int32, np.int64]
     for t in integers:
         self.assertEqual(as_json_table_type(t), 'integer')
Exemplo n.º 22
0
 def test_as_json_table_type_float_dtypes(self, float_dtype):
     assert as_json_table_type(float_dtype) == 'number'
Exemplo n.º 23
0
 def test_as_json_table_type_date_dtypes(self, date_dtype):
     # TODO: datedate.date? datetime.time?
     assert as_json_table_type(date_dtype) == 'datetime'
Exemplo n.º 24
0
 def test_as_json_table_type_int_data(self):
     int_data = [1, 2, 3]
     int_types = [np.int, np.int16, np.int32, np.int64]
     for t in int_types:
         self.assertEqual(as_json_table_type(np.array(int_data, dtype=t)),
                          'integer')
Exemplo n.º 25
0
 def test_as_json_table_type_bool_data(self):
     bool_data = [True, False]
     bool_types = [bool, np.bool]
     for t in bool_types:
         self.assertEqual(as_json_table_type(np.array(bool_data, dtype=t)),
                          'boolean')
Exemplo n.º 26
0
 def test_as_json_table_type_bool_dtypes(self):
     bools = [bool, np.bool]
     for t in bools:
         assert as_json_table_type(t) == 'boolean'
Exemplo n.º 27
0
 def test_as_json_table_type_bool_data(self):
     bool_data = [True, False]
     bool_types = [bool, np.bool]
     for t in bool_types:
         self.assertEqual(as_json_table_type(np.array(bool_data, dtype=t)),
                          'boolean')
Exemplo n.º 28
0
 def test_as_json_table_type_string_dtypes(self):
     strings = [object]  # TODO
     for t in strings:
         assert as_json_table_type(t) == 'string'
Exemplo n.º 29
0
 def test_as_json_table_type_int_data(self):
     int_data = [1, 2, 3]
     int_types = [np.int, np.int16, np.int32, np.int64]
     for t in int_types:
         self.assertEqual(as_json_table_type(np.array(int_data, dtype=t)),
                          'integer')
Exemplo n.º 30
0
 def test_as_json_table_type_string_data(self):
     strings = [pd.Series(['a', 'b']), pd.Index(['a', 'b'])]
     for t in strings:
         self.assertEqual(as_json_table_type(t), 'string')
Exemplo n.º 31
0
 def test_as_json_table_type_timedelta_dtypes(self):
     durations = [np.timedelta64, np.dtype("<m8[ns]")]
     for t in durations:
         assert as_json_table_type(t) == 'duration'
Exemplo n.º 32
0
 def test_as_json_table_type_bool_data(self, bool_type):
     bool_data = [True, False]
     assert as_json_table_type(np.array(
         bool_data, dtype=bool_type)) == 'boolean'
Exemplo n.º 33
0
 def test_as_json_table_type_categorical_dtypes(self):
     assert as_json_table_type(pd.Categorical) == 'any'
     assert as_json_table_type(CategoricalDtype()) == 'any'
Exemplo n.º 34
0
 def test_as_json_table_type_date_data(self, date_data):
     assert as_json_table_type(date_data) == 'datetime'
Exemplo n.º 35
0
 def test_as_json_table_type_int_data(self, int_type):
     int_data = [1, 2, 3]
     assert as_json_table_type(np.array(int_data,
                                        dtype=int_type)) == 'integer'
Exemplo n.º 36
0
 def test_as_json_table_type_string_data(self, str_data):
     assert as_json_table_type(str_data) == 'string'
Exemplo n.º 37
0
 def test_as_json_table_type_bool_data(self, bool_type):
     bool_data = [True, False]
     assert as_json_table_type(np.array(bool_data,
                                        dtype=bool_type)) == 'boolean'
Exemplo n.º 38
0
 def test_as_json_table_type_categorical_data(self, cat_data):
     assert as_json_table_type(cat_data) == 'any'
Exemplo n.º 39
0
 def test_as_json_table_type_string_data(self, str_data):
     assert as_json_table_type(str_data) == 'string'
Exemplo n.º 40
0
 def test_as_json_table_type_int_dtypes(self, int_dtype):
     assert as_json_table_type(int_dtype) == 'integer'
Exemplo n.º 41
0
 def test_as_json_table_type_int_dtypes(self, int_dtype):
     assert as_json_table_type(int_dtype) == 'integer'
Exemplo n.º 42
0
 def test_as_json_table_type_float_dtypes(self, float_dtype):
     assert as_json_table_type(float_dtype) == 'number'
Exemplo n.º 43
0
 def test_as_json_table_type_bool_dtypes(self, bool_dtype):
     assert as_json_table_type(bool_dtype) == 'boolean'
Exemplo n.º 44
0
 def test_as_json_table_type_bool_dtypes(self, bool_dtype):
     assert as_json_table_type(bool_dtype) == 'boolean'
Exemplo n.º 45
0
 def test_as_json_table_type_timedelta_dtypes(self, td_dtype):
     assert as_json_table_type(td_dtype) == 'duration'
Exemplo n.º 46
0
 def test_as_json_table_type_date_dtypes(self, date_dtype):
     # TODO: datedate.date? datetime.time?
     assert as_json_table_type(date_dtype) == 'datetime'
Exemplo n.º 47
0
 def test_as_json_table_type_categorical_dtypes(self):
     # TODO: I think before is_categorical_dtype(Categorical)
     # returned True, but now it's False. Figure out why or
     # if it matters
     assert as_json_table_type(pd.Categorical(['a'])) == 'any'
     assert as_json_table_type(CategoricalDtype()) == 'any'
Exemplo n.º 48
0
 def test_as_json_table_type_timedelta_dtypes(self, td_dtype):
     assert as_json_table_type(td_dtype) == 'duration'
Exemplo n.º 49
0
 def test_as_json_table_type_int_dtypes(self):
     integers = [np.int, np.int16, np.int32, np.int64]
     for t in integers:
         self.assertEqual(as_json_table_type(t), 'integer')
Exemplo n.º 50
0
 def test_as_json_table_type_bool_dtypes(self):
     bools = [bool, np.bool]
     for t in bools:
         self.assertEqual(as_json_table_type(t), 'boolean')
Exemplo n.º 51
0
 def test_as_json_table_type_string_dtypes(self, str_dtype):
     assert as_json_table_type(str_dtype) == 'string'
Exemplo n.º 52
0
 def test_as_json_table_type_string_dtypes(self):
     strings = [object]  # TODO
     for t in strings:
         assert as_json_table_type(t) == 'string'
Exemplo n.º 53
0
 def test_as_json_table_type_float_dtypes(self):
     floats = [np.float, np.float16, np.float32, np.float64]
     for t in floats:
         self.assertEqual(as_json_table_type(t), 'number')
Exemplo n.º 54
0
 def test_as_json_table_type_categorical_dtypes(self):
     # TODO: I think before is_categorical_dtype(Categorical)
     # returned True, but now it's False. Figure out why or
     # if it matters
     assert as_json_table_type(pd.Categorical(['a'])) == 'any'
     assert as_json_table_type(CategoricalDtype()) == 'any'
Exemplo n.º 55
0
 def test_as_json_table_type_timedelta_dtypes(self):
     durations = [np.timedelta64, np.dtype("<m8[ns]")]
     for t in durations:
         self.assertEqual(as_json_table_type(t), 'duration')
Exemplo n.º 56
0
 def test_as_json_table_type_int_data(self, int_type):
     int_data = [1, 2, 3]
     assert as_json_table_type(np.array(
         int_data, dtype=int_type)) == 'integer'
Exemplo n.º 57
0
 def test_as_json_table_type_categorical_dtypes(self):
     self.assertEqual(as_json_table_type(pd.Categorical), 'any')
     self.assertEqual(as_json_table_type(CategoricalDtype()), 'any')
Exemplo n.º 58
0
 def test_as_json_table_type_float_data(self, float_type):
     float_data = [1., 2., 3.]
     assert as_json_table_type(np.array(
         float_data, dtype=float_type)) == 'number'
Exemplo n.º 59
0
 def test_as_json_table_type_bool_dtypes(self):
     bools = [bool, np.bool]
     for t in bools:
         assert as_json_table_type(t) == 'boolean'
Exemplo n.º 60
0
 def test_as_json_table_type_float_dtypes(self):
     floats = [np.float, np.float16, np.float32, np.float64]
     for t in floats:
         assert as_json_table_type(t) == 'number'