File tree 1 file changed +26
-1
lines changed
1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 3
3
import pytest
4
4
import numpy as np
5
5
6
- from pandas import DataFrame , Index
6
+ from pandas import DataFrame , Index , PeriodIndex
7
7
from pandas .tests .frame .common import TestData
8
8
import pandas .util .testing as tm
9
9
10
+ @pytest .fixture
11
+ def frame_with_period_index ():
12
+ return DataFrame (
13
+ data = np .arange (20 ).reshape (4 ,5 ),
14
+ columns = list ('abcde' ),
15
+ index = PeriodIndex (start = '2000' , freq = 'A' , periods = 4 ))
16
+
10
17
11
18
@pytest .fixture
12
19
def frame ():
@@ -139,3 +146,21 @@ def test_join_overlap(frame):
139
146
140
147
# column order not necessarily sorted
141
148
tm .assert_frame_equal (joined , expected .loc [:, joined .columns ])
149
+
150
+ def test_join_period_index (frame_with_period_index ):
151
+ other = frame_with_period_index .rename (
152
+ columns = lambda x : '{key}{key}' .format (key = x ))
153
+
154
+ joined_values = np .concatenate (
155
+ [frame_with_period_index .values ] * 2 , axis = 1 )
156
+
157
+ joined_cols = frame_with_period_index .columns .append (other .columns )
158
+
159
+ joined = frame_with_period_index .join (other )
160
+ expected = DataFrame (
161
+ data = joined_values ,
162
+ columns = joined_cols ,
163
+ index = frame_with_period_index .index )
164
+
165
+ tm .assert_frame_equal (joined , expected )
166
+
You can’t perform that action at this time.
0 commit comments