-
- Notifications
You must be signed in to change notification settings - Fork 19.3k
CLN avoid some upcasting when its not the purpose of the test #50493
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -448,7 +448,7 @@ def test_date_index_query(self): | |
| def test_date_index_query_with_NaT(self): | ||
| engine, parser = self.engine, self.parser | ||
| n = 10 | ||
| df = DataFrame(np.random.randn(n, 3)) | ||
| df = DataFrame(np.random.randn(n, 3)).astype({0: object}) | ||
| df["dates1"] = date_range("1/1/2012", periods=n) | ||
| df["dates3"] = date_range("1/1/2014", periods=n) | ||
| df.iloc[0, 0] = pd.NaT | ||
| | @@ -808,7 +808,7 @@ def test_date_index_query(self): | |
| def test_date_index_query_with_NaT(self): | ||
| engine, parser = self.engine, self.parser | ||
| n = 10 | ||
| df = DataFrame(np.random.randn(n, 3)) | ||
| df = DataFrame(np.random.randn(n, 3)).astype({0: object}) | ||
| df["dates1"] = date_range("1/1/2012", periods=n) | ||
| df["dates3"] = date_range("1/1/2014", periods=n) | ||
| df.iloc[0, 0] = pd.NaT | ||
| Member Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above | ||
| | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -448,11 +448,15 @@ def test_var_std(self, datetime_frame): | |
| @pytest.mark.parametrize("meth", ["sem", "var", "std"]) | ||
| def test_numeric_only_flag(self, meth): | ||
| # GH 9201 | ||
| df1 = DataFrame(np.random.randn(5, 3), columns=["foo", "bar", "baz"]) | ||
| df1 = DataFrame(np.random.randn(5, 3), columns=["foo", "bar", "baz"]).astype( | ||
| {"foo": object} | ||
| ) | ||
| # set one entry to a number in str format | ||
| df1.loc[0, "foo"] = "100" | ||
| | ||
| df2 = DataFrame(np.random.randn(5, 3), columns=["foo", "bar", "baz"]) | ||
| df2 = DataFrame(np.random.randn(5, 3), columns=["foo", "bar", "baz"]).astype( | ||
| {"foo": object} | ||
| ) | ||
| # set one entry to a non-number str | ||
| df2.loc[0, "foo"] = "a" | ||
| Member Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in both Might as well declare column | ||
| | ||
| | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -102,7 +102,7 @@ def test_groupby_with_timegrouper(self): | |
| index=date_range( | ||
| "20130901", "20131205", freq="5D", name="Date", inclusive="left" | ||
| ), | ||
| ) | ||
| ).astype({"Buyer": object}) | ||
| ||
| expected.iloc[0, 0] = "CarlCarlCarl" | ||
| expected.iloc[6, 0] = "CarlCarl" | ||
| expected.iloc[18, 0] = "Joe" | ||
| | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -16,7 +16,7 @@ def test_replace_explicit_none(self): | |
| expected = pd.Series([0, 0, None], dtype=object) | ||
| tm.assert_series_equal(result, expected) | ||
| | ||
| df = pd.DataFrame(np.zeros((3, 3))) | ||
| df = pd.DataFrame(np.zeros((3, 3))).astype({2: object}) | ||
| df.iloc[2, 2] = "" | ||
| Member Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the third column might as well set to | ||
| result = df.replace("", None) | ||
| expected = pd.DataFrame( | ||
| | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here,
df[0]is first created ofintdtype, and thendf.iloc[0, 0] = pd.NaTupcasts it toobject. Might as well create it of dtypeobjectin the first place, as the purpose of this test comes in the lines below (df.query(...)