Skip to content

Commit 6ca64c5

Browse files
committed
REF/TST: collect reindex tests
1 parent 2f55283 commit 6ca64c5

File tree

6 files changed

+539
-518
lines changed

6 files changed

+539
-518
lines changed

pandas/tests/frame/methods/test_align.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
import numpy as np
22
import pytest
3+
import pytz
34

45
import pandas as pd
5-
from pandas import DataFrame, Index, Series
6+
from pandas import DataFrame, Index, Series, date_range
67
import pandas._testing as tm
78

89

910
class TestDataFrameAlign:
11+
def test_frame_align_aware(self):
12+
idx1 = date_range("2001", periods=5, freq="H", tz="US/Eastern")
13+
idx2 = date_range("2001", periods=5, freq="2H", tz="US/Eastern")
14+
df1 = DataFrame(np.random.randn(len(idx1), 3), idx1)
15+
df2 = DataFrame(np.random.randn(len(idx2), 3), idx2)
16+
new1, new2 = df1.align(df2)
17+
assert df1.index.tz == new1.index.tz
18+
assert df2.index.tz == new2.index.tz
19+
20+
# different timezones convert to UTC
21+
22+
# frame with frame
23+
df1_central = df1.tz_convert("US/Central")
24+
new1, new2 = df1.align(df1_central)
25+
assert new1.index.tz == pytz.UTC
26+
assert new2.index.tz == pytz.UTC
27+
28+
# frame with Series
29+
new1, new2 = df1.align(df1_central[0], axis=0)
30+
assert new1.index.tz == pytz.UTC
31+
assert new2.index.tz == pytz.UTC
32+
33+
df1[0].align(df1_central, axis=0)
34+
assert new1.index.tz == pytz.UTC
35+
assert new2.index.tz == pytz.UTC
36+
1037
def test_align_float(self, float_frame):
1138
af, bf = float_frame.align(float_frame)
1239
assert af._mgr is not float_frame._mgr

0 commit comments

Comments
 (0)