@@ -2858,8 +2858,9 @@ def test_pivot_with_pyarrow_categorical(self):
2858
2858
# GH#53051
2859
2859
pa = pytest .importorskip ("pyarrow" )
2860
2860
2861
+ data = {"string_column" : ["A" , "B" , "C" ], "number_column" : [1 , 2 , 3 ]}
2861
2862
df = (
2862
- DataFrame ({ "string_column" : [ "A" , "B" , "C" ], "number_column" : [ 1 , 2 , 3 ]} )
2863
+ DataFrame (data )
2863
2864
.astype ({"string_column" : "category" , "number_column" : "float32" })
2864
2865
.astype (
2865
2866
{
@@ -2871,14 +2872,7 @@ def test_pivot_with_pyarrow_categorical(self):
2871
2872
2872
2873
df = df .pivot (columns = ["string_column" ], values = ["number_column" ])
2873
2874
2874
- multi_index = MultiIndex .from_arrays (
2875
- [["number_column" , "number_column" , "number_column" ], ["A" , "B" , "C" ]],
2876
- names = (None , "string_column" ),
2877
- )
2878
- df_expected = DataFrame (
2879
- [[1.0 , np .nan , np .nan ], [np .nan , 2.0 , np .nan ], [np .nan , np .nan , 3.0 ]],
2880
- columns = multi_index ,
2881
- )
2875
+ df_expected = DataFrame (data ).pivot (columns = ["string_column" ], values = ["number_column" ])
2882
2876
tm .assert_frame_equal (
2883
2877
df , df_expected , check_dtype = False , check_column_type = False
2884
2878
)
0 commit comments