Skip to content

TST: test_column_types_consistent #42725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 28, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pandas/tests/generic/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
MultiIndex,
Series,
date_range,
Timestamp,
)
import pandas._testing as tm
from pandas.tests.generic.test_generic import Generic
Expand Down Expand Up @@ -87,6 +88,37 @@ def test_metadata_propagation_indiv_resample(self):
result = df.resample("1T")
self.check_metadata(df, result)

def test_column_types_consistent(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move to tests/frame/indexing/test_loc.py

# GH 26779
df = DataFrame(
data={
"channel": [1, 2, 3],
"A": ["String 1", np.NaN, "String 2"],
"B": [
Timestamp("2019-06-11 11:00:00"),
np.NaN,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coud you use pd.NaT for clairty?

Timestamp("2019-06-11 12:00:00"),
],
}
)
df2 = DataFrame(
data={"A": ["String 3"], "B": [Timestamp("2019-06-11 12:00:00")]}
)
# Change Columns A and B to df2.values wherever Column A is NaN
df.loc[df["A"].isna(), ["A", "B"]] = df2.values
expected = DataFrame(
data={
"channel": [1, 2, 3],
"A": ["String 1", "String 3", "String 2"],
"B": [
Timestamp("2019-06-11 11:00:00"),
Timestamp("2019-06-11 12:00:00"),
Timestamp("2019-06-11 12:00:00"),
],
}
)
tm.assert_frame_equal(df, expected)

def test_metadata_propagation_indiv(self):
# merging with override
# GH 6923
Expand Down