-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST/REF: collect tests by method from test_io (#37451)
- Loading branch information
1 parent
d391e0b
commit be1728a
Showing
3 changed files
with
66 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from pandas import DataFrame, Series | ||
import pandas._testing as tm | ||
|
||
|
||
class TestToFrame: | ||
def test_to_frame(self, datetime_series): | ||
datetime_series.name = None | ||
rs = datetime_series.to_frame() | ||
xp = DataFrame(datetime_series.values, index=datetime_series.index) | ||
tm.assert_frame_equal(rs, xp) | ||
|
||
datetime_series.name = "testname" | ||
rs = datetime_series.to_frame() | ||
xp = DataFrame( | ||
dict(testname=datetime_series.values), index=datetime_series.index | ||
) | ||
tm.assert_frame_equal(rs, xp) | ||
|
||
rs = datetime_series.to_frame(name="testdifferent") | ||
xp = DataFrame( | ||
dict(testdifferent=datetime_series.values), index=datetime_series.index | ||
) | ||
tm.assert_frame_equal(rs, xp) | ||
|
||
def test_to_frame_expanddim(self): | ||
# GH#9762 | ||
|
||
class SubclassedSeries(Series): | ||
@property | ||
def _constructor_expanddim(self): | ||
return SubclassedFrame | ||
|
||
class SubclassedFrame(DataFrame): | ||
pass | ||
|
||
ser = SubclassedSeries([1, 2, 3], name="X") | ||
result = ser.to_frame() | ||
assert isinstance(result, SubclassedFrame) | ||
expected = SubclassedFrame({"X": [1, 2, 3]}) | ||
tm.assert_frame_equal(result, expected) |