forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_to_frame.py
31 lines (27 loc) · 1.12 KB
/
test_to_frame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pandas import (
DataFrame,
Index,
date_range,
)
import pandas._testing as tm
class TestToFrame:
def test_to_frame_datetime_tz(self):
# GH#25809
idx = date_range(start="2019-01-01", end="2019-01-30", freq="D", tz="UTC")
result = idx.to_frame()
expected = DataFrame(idx, index=idx)
tm.assert_frame_equal(result, expected)
def test_to_frame_respects_none_name(self):
# GH#44212 if we explicitly pass name=None, then that should be respected,
# not changed to 0
# GH-45448 this is first deprecated to only change in the future
idx = date_range(start="2019-01-01", end="2019-01-30", freq="D", tz="UTC")
with tm.assert_produces_warning(FutureWarning):
result = idx.to_frame(name=None)
# exp_idx = Index([None], dtype=object)
exp_idx = Index([0])
tm.assert_index_equal(exp_idx, result.columns)
with tm.assert_produces_warning(FutureWarning):
result = idx.rename("foo").to_frame(name=None)
exp_idx = Index(["foo"], dtype=object)
tm.assert_index_equal(exp_idx, result.columns)