@@ -12164,6 +12164,47 @@ def test_concat_empty_dataframe_dtypes(self):
12164
12164
self .assertEqual (result ['b' ].dtype , np .float64 )
12165
12165
self .assertEqual (result ['c' ].dtype , np .float64 )
12166
12166
12167
+ def test_empty_frame_dtypes_ftypes (self ):
12168
+ empty_df = pd .DataFrame ()
12169
+ assert_series_equal (empty_df .dtypes , pd .Series (dtype = np .object ))
12170
+ assert_series_equal (empty_df .ftypes , pd .Series (dtype = np .object ))
12171
+
12172
+ nocols_df = pd .DataFrame (index = [1 ,2 ,3 ])
12173
+ assert_series_equal (nocols_df .dtypes , pd .Series (dtype = np .object ))
12174
+ assert_series_equal (nocols_df .ftypes , pd .Series (dtype = np .object ))
12175
+
12176
+ norows_df = pd .DataFrame (columns = list ("abc" ))
12177
+ assert_series_equal (norows_df .dtypes , pd .Series (np .object , index = list ("abc" )))
12178
+ assert_series_equal (norows_df .ftypes , pd .Series ('object:dense' , index = list ("abc" )))
12179
+
12180
+ norows_int_df = pd .DataFrame (columns = list ("abc" )).astype (np .int32 )
12181
+ assert_series_equal (norows_int_df .dtypes , pd .Series (np .dtype ('int32' ), index = list ("abc" )))
12182
+ assert_series_equal (norows_int_df .ftypes , pd .Series ('int32:dense' , index = list ("abc" )))
12183
+
12184
+ odict = OrderedDict
12185
+ df = pd .DataFrame (odict ([('a' , 1 ), ('b' , True ), ('c' , 1.0 )]), index = [1 , 2 , 3 ])
12186
+ assert_series_equal (df .dtypes , pd .Series (odict ([('a' , np .int64 ),
12187
+ ('b' , np .bool ),
12188
+ ('c' , np .float64 )])))
12189
+ assert_series_equal (df .ftypes , pd .Series (odict ([('a' , 'int64:dense' ),
12190
+ ('b' , 'bool:dense' ),
12191
+ ('c' , 'float64:dense' )])))
12192
+
12193
+ # same but for empty slice of df
12194
+ assert_series_equal (df [:0 ].dtypes , pd .Series (odict ([('a' , np .int ),
12195
+ ('b' , np .bool ),
12196
+ ('c' , np .float )])))
12197
+ assert_series_equal (df [:0 ].ftypes , pd .Series (odict ([('a' , 'int64:dense' ),
12198
+ ('b' , 'bool:dense' ),
12199
+ ('c' , 'float64:dense' )])))
12200
+
12201
+ def skip_if_no_ne (engine = 'numexpr' ):
12202
+ if engine == 'numexpr' :
12203
+ try :
12204
+ import numexpr as ne
12205
+ except ImportError :
12206
+ raise nose .SkipTest ("cannot query engine numexpr when numexpr not "
12207
+ "installed" )
12167
12208
12168
12209
12169
12210
def skip_if_no_pandas_parser (parser ):
0 commit comments