#NEWLINE# def test_constructor_for_list_with_dtypes( self ) : #NEWLINE# #INDENT# intname = np . dtype ( np . int_ ) . name #NEWLINE# floatname = np . dtype ( np . float_ ) . name #NEWLINE# datetime64name = np . dtype ( 'M8[ns]' ) . name #NEWLINE# objectname = np . dtype ( np . object_ ) . name #NEWLINE# df = DataFrame ( [ np . arange ( 5 ) for x in range ( 5 ) ] ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'int64' : 5 , #NEWLINE# #UNINDENT# } ) #NEWLINE# df = DataFrame ( [ np . array ( np . arange ( 5 ) , dtype = 'int32' ) for x in range ( 5 ) ] ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'int32' : 5 , #NEWLINE# #UNINDENT# } ) #NEWLINE# df = DataFrame ( { #NEWLINE# #INDENT# 'a' : [ ( 2 ** 31 ) , ( ( 2 ** 31 ) + 1 ) ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'int64' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# df = DataFrame ( [ 1 , 2 ] ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'int64' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# df = DataFrame ( [ 1.0 , 2.0 ] ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'float64' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# df = DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 2 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'int64' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# df = DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1.0 , 2.0 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'float64' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# df = DataFrame ( { #NEWLINE# #INDENT# 'a' : 1 , #NEWLINE# #UNINDENT# } , index = lrange ( 3 ) ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'int64' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# df = DataFrame ( { #NEWLINE# #INDENT# 'a' : 1.0 , #NEWLINE# #UNINDENT# } , index = lrange ( 3 ) ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'float64' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# df = DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 2 , 4 , 7 ] , #NEWLINE# 'b' : [ 1.2 , 2.3 , 5.1 , 6.3 ] , #NEWLINE# 'c' : list ( 'abcd' ) , #NEWLINE# 'd' : [ datetime ( 2000 , 1 , 1 ) for i in range ( 4 ) ] , #NEWLINE# 'e' : [ 1.0 , 2 , 4.0 , 7 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = df . get_dtype_counts ( ) #NEWLINE# expected = Series ( { #NEWLINE# #INDENT# 'int64' : 1 , #NEWLINE# 'float64' : 2 , #NEWLINE# datetime64name : 1 , #NEWLINE# objectname : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# result . sort_index ( ) #NEWLINE# expected . sort_index ( ) #NEWLINE# assert_series_equal ( result , expected )