@@ -150,6 +150,25 @@ def test_build_dataframe_from_csv(self):
150150
151151 pd ._testing .assert_frame_equal (expected_df , df , check_column_type = False )
152152
153+ def test_build_dataframe_from_csv_shaped_numbers_and_strings (self ):
154+ raw_csv = "Region~Product~Measure~Value\r \n " "r1~p1~Revenue~1.0\r \n " "r1~p2~Revenue~3.0\r \n " "r1~p1~Comment~Great Product\r \n " "r1~p2~Comment~"
155+ df = build_dataframe_from_csv (raw_csv , dtype = {"Revenue" : float }, shaped = True )
156+
157+ expected_df = pd .DataFrame (
158+ {
159+ "Region" : ["r1" , "r1" ],
160+ "Product" : ["p1" , "p2" ],
161+ "Comment" : ["Great Product" , "" ],
162+ "Revenue" : [1.00000 , 3.00000 ],
163+ }
164+ )
165+
166+ # explicit conversion for exact comparison
167+ expected_df ["Revenue" ] = expected_df ["Revenue" ].astype (float )
168+ df ["Revenue" ] = df ["Revenue" ].astype (float )
169+
170+ pd ._testing .assert_frame_equal (expected_df , df )
171+
153172 def test_build_dataframe_from_csv_shaped (self ):
154173 raw_csv = "Region~Product~Measure~Value\r \n " "r1~p1~Revenue~1.0\r \n " "r1~p2~Revenue~3.0\r \n " "r2~p2~Revenue~4.0"
155174 df = build_dataframe_from_csv (raw_csv , dtype = {"Revenue" : float }, shaped = True )
0 commit comments