@@ -1883,10 +1883,9 @@ def test_agg_lambda_pyarrow_to_same_data_type():
1883
1883
assert result ["B" ].dtype == expected ["B" ].dtype
1884
1884
1885
1885
1886
- def test_agg_lambda_pyarrow_to_data_type_conversion ():
1887
- # test numpy datatype conversion back to pyarrow datatype
1886
+ def test_agg_lambda_float64_pyarrow_dtype_conversion ():
1887
+ # test numpy dtype conversion back to pyarrow dtype
1888
1888
# complexes, floats, ints, uints, object
1889
- # float64
1890
1889
df = DataFrame ({"A" : ["c1" , "c2" , "c3" ], "B" : [100 , 200 , 255 ]})
1891
1890
df ["B" ] = df ["B" ].astype ("float64[pyarrow]" )
1892
1891
gb = df .groupby ("A" )
@@ -1899,7 +1898,9 @@ def test_agg_lambda_pyarrow_to_data_type_conversion():
1899
1898
tm .assert_frame_equal (result , expected )
1900
1899
assert result ["B" ].dtype == expected ["B" ].dtype
1901
1900
1902
- # complex128
1901
+
1902
+ def test_agg_lambda_complex128_pyarrow_dtype_conversion ():
1903
+ df = DataFrame ({"A" : ["c1" , "c2" , "c3" ], "B" : [100 , 200 , 255 ]})
1903
1904
df ["B" ] = df ["B" ].astype ("int64[pyarrow]" )
1904
1905
gb = df .groupby ("A" )
1905
1906
result = gb .agg (lambda x : complex (x .sum (), x .count ()))
@@ -1916,7 +1917,8 @@ def test_agg_lambda_pyarrow_to_data_type_conversion():
1916
1917
tm .assert_frame_equal (result , expected )
1917
1918
assert result ["B" ].dtype == expected ["B" ].dtype
1918
1919
1919
- # int64
1920
+
1921
+ def test_agg_lambda_int64_pyarrow_dtype_conversion ():
1920
1922
df = DataFrame ({"A" : ["c1" , "c2" , "c3" ], "B" : [100 , 200 , 255 ]})
1921
1923
df ["B" ] = df ["B" ].astype ("int64[pyarrow]" )
1922
1924
gb = df .groupby ("A" )
@@ -1929,7 +1931,8 @@ def test_agg_lambda_pyarrow_to_data_type_conversion():
1929
1931
tm .assert_frame_equal (result , expected )
1930
1932
assert result ["B" ].dtype == expected ["B" ].dtype
1931
1933
1932
- # uint64
1934
+
1935
+ def test_agg_lambda_uint64_pyarrow_dtype_conversion ():
1933
1936
df = DataFrame ({"A" : ["c1" , "c2" , "c3" ], "B" : [100 , 200 , 255 ]})
1934
1937
df ["B" ] = df ["B" ].astype ("uint64[pyarrow]" )
1935
1938
gb = df .groupby ("A" )
@@ -1939,7 +1942,11 @@ def test_agg_lambda_pyarrow_to_data_type_conversion():
1939
1942
expected ["B" ] = expected ["B" ].astype ("int64[pyarrow]" )
1940
1943
expected .set_index ("A" , inplace = True )
1941
1944
1942
- # uint64 casted
1945
+ tm .assert_frame_equal (result , expected )
1946
+ assert result ["B" ].dtype == expected ["B" ].dtype
1947
+
1948
+
1949
+ def test_agg_lambda_numpy_uint64_to_pyarrow_dtype_conversion ():
1943
1950
df = DataFrame ({"A" : ["c1" , "c2" , "c3" ], "B" : [100 , 200 , 255 ]})
1944
1951
df ["B" ] = df ["B" ].astype ("uint64[pyarrow]" )
1945
1952
gb = df .groupby ("A" )
@@ -1952,7 +1959,8 @@ def test_agg_lambda_pyarrow_to_data_type_conversion():
1952
1959
tm .assert_frame_equal (result , expected )
1953
1960
assert result ["B" ].dtype == expected ["B" ].dtype
1954
1961
1955
- # bool
1962
+
1963
+ def test_agg_lambda_bool_pyarrow_dtype_conversion ():
1956
1964
df = DataFrame ({"A" : ["c1" , "c2" , "c3" ], "B" : [100 , 200 , 255 ]})
1957
1965
df ["B" ] = df ["B" ].astype ("bool[pyarrow]" )
1958
1966
gb = df .groupby ("A" )
@@ -1965,7 +1973,8 @@ def test_agg_lambda_pyarrow_to_data_type_conversion():
1965
1973
tm .assert_frame_equal (result , expected )
1966
1974
assert result ["B" ].dtype == expected ["B" ].dtype
1967
1975
1968
- # object
1976
+
1977
+ def test_agg_lambda_object_pyarrow_dtype_conversion ():
1969
1978
df = DataFrame ({"A" : ["c1" , "c2" , "c3" ], "B" : [100 , 200 , 255 ]})
1970
1979
df ["B" ] = df ["B" ].astype ("int64[pyarrow]" )
1971
1980
gb = df .groupby ("A" )
0 commit comments