1
- import numpy as np
2
- import pytest
3
-
4
1
import pandas as pd
5
2
import pandas ._testing as tm
6
3
@@ -9,25 +6,19 @@ class TestMap:
9
6
def test_map (self ):
10
7
# map test on StringDType, GH#40823
11
8
df1 = pd .DataFrame (
12
- {
13
- "col1" : [ pd . NA , "foo " , "bar" ]
14
- }, index = [ "id1" , "id2" , "id3" ], dtype = pd .StringDtype ()
9
+ {"col1" : [ pd . NA , "foo" , "bar" ]},
10
+ index = [ "id1" , "id2 " , "id3" ],
11
+ dtype = pd .StringDtype (),
15
12
)
16
13
17
- df2 = pd .DataFrame (
18
- {
19
- "id" : ["id4" , "id2" , "id1" ]
20
- }, dtype = pd .StringDtype ()
21
- )
22
-
14
+ df2 = pd .DataFrame ({"id" : ["id4" , "id2" , "id1" ]}, dtype = pd .StringDtype ())
15
+
23
16
df2 ["col1" ] = df2 ["id" ].map (df1 ["col1" ])
24
-
17
+
25
18
result = df2
26
19
expected = pd .DataFrame (
27
- {
28
- "id" : ["id4" , "id2" , "id1" ],
29
- "col1" : [pd .NA , "foo" , pd .NA ]
30
- }, dtype = pd .StringDtype ()
20
+ {"id" : ["id4" , "id2" , "id1" ], "col1" : [pd .NA , "foo" , pd .NA ]},
21
+ dtype = pd .StringDtype (),
31
22
)
32
-
33
- tm .assert_frame_equal (result , expected )
23
+
24
+ tm .assert_frame_equal (result , expected )
0 commit comments