@@ -1874,6 +1874,52 @@ def test_pipe_panel(self):
1874
1874
with tm .assertRaises (ValueError ):
1875
1875
result = wp .pipe ((f , 'y' ), x = 1 , y = 1 )
1876
1876
1877
+ def test_align_joins (self ):
1878
+ df = DataFrame (np .array ([[1. , 2. ], [3. , 4. ]]), columns = list ('AB' ))
1879
+ ts = Series ([5. , 6. , 7. ])
1880
+ check = df .align (ts , join = 'outer' , axis = 0 , broadcast_axis = 1 )
1881
+ df1 = DataFrame (check [0 ])
1882
+ df2 = DataFrame (check [1 ])
1883
+ expected1 = DataFrame (np .array ([[1. , 2. ], [3. , 4. ],
1884
+ [pd .np .nan , pd .np .nan ]]),
1885
+ columns = list ('AB' ))
1886
+ expected2 = DataFrame (np .array ([[5. , 5. ], [6. , 6. ], [7. , 7. ]]),
1887
+ columns = list ('AB' ))
1888
+ assert_frame_equal (df1 , expected1 )
1889
+ assert_frame_equal (df2 , expected2 )
1890
+
1891
+ check = df .align (ts , join = 'inner' , axis = 0 , broadcast_axis = 1 )
1892
+ df1 = DataFrame (check [0 ])
1893
+ df2 = DataFrame (check [1 ])
1894
+ expected1 = DataFrame (np .array ([[1. , 2. ], [3. , 4. ]]),
1895
+ columns = list ('AB' ))
1896
+ expected2 = DataFrame (np .array ([[5. , 5. ], [6. , 6. ]]),
1897
+ columns = list ('AB' ))
1898
+ assert_frame_equal (df1 , expected1 )
1899
+ assert_frame_equal (df2 , expected2 )
1900
+
1901
+ check = df .align (ts , join = 'left' , axis = 0 , broadcast_axis = 1 )
1902
+ df1 = DataFrame (check [0 ])
1903
+ df2 = DataFrame (check [1 ])
1904
+ expected1 = DataFrame (np .array ([[1. , 2. ], [3. , 4. ]]),
1905
+ columns = list ('AB' ))
1906
+ expected2 = DataFrame (np .array ([[5. , 5. ], [6. , 6. ]]),
1907
+ columns = list ('AB' ))
1908
+ assert_frame_equal (df1 , expected1 )
1909
+ assert_frame_equal (df2 , expected2 )
1910
+
1911
+ check = df .align (ts , join = 'right' , axis = 0 , broadcast_axis = 1 )
1912
+ df1 = DataFrame (check [0 ])
1913
+ df2 = DataFrame (check [1 ])
1914
+ expected1 = DataFrame (np .array ([[1. , 2. ], [3. , 4. ],
1915
+ [pd .np .nan , pd .np .nan ]]),
1916
+ columns = list ('AB' ))
1917
+ expected2 = DataFrame (np .array ([[5. , 5. ], [6. , 6. ], [7. , 7. ]]),
1918
+ columns = list ('AB' ))
1919
+ assert_frame_equal (df1 , expected1 )
1920
+ assert_frame_equal (df2 , expected2 )
1921
+
1922
+
1877
1923
if __name__ == '__main__' :
1878
1924
nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
1879
1925
exit = False )
0 commit comments