Skip to content

add concat function dtype test #51816

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 1 commit into from
Mar 10, 2023
Merged

Conversation

liang3zy22
Copy link
Contributor

@liang3zy22 liang3zy22 commented Mar 7, 2023

The old PR closed, so created new one to close #32934.

@liang3zy22 liang3zy22 force-pushed the testconcatfunc branch 2 times, most recently from 009cdab to b25b0b2 Compare March 7, 2023 09:29
@liang3zy22
Copy link
Contributor Author

1 check failed with current code,Ubuntu/Data Manager. It means that the code
pd.concat([df_time, df_float.iloc[:0]])
has data type "object".
If I updated the codes to the following code:
tm.assert_equal( pd.concat([df_time, df_float.iloc[:0]]), pd.DataFrame({"A": pd.array(["2000"], dtype="datetime64[ns]")}).astype({"A":"object"}), )
The Ubuntu/Data manager will pass, but other 21 checks will fail since the code
pd.concat([df_time, df_float.iloc[:0]])
may have data type "datetime64" in these 21 checks(I only checked some).

df_time = pd.DataFrame({"A": pd.array(["2000"], dtype="datetime64[ns]")})
df_float = pd.DataFrame({"A": pd.array([1.0], dtype="float64")})

tm.assert_equal(
Copy link
Member

Choose a reason for hiding this comment

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

For each of these:

  1. Could you use tm.assert_frame_equal
  2. Create variables expected = ... , result = ...

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Mar 7, 2023
@liang3zy22 liang3zy22 force-pushed the testconcatfunc branch 2 times, most recently from 085a22e to f97b6d4 Compare March 8, 2023 07:00
@mroeschke
Copy link
Member

Looks like the using_array_manager fixture needs to be used to set the dtype for the last example

@@ -2436,3 +2436,40 @@ def test_dt64arr_addsub_object_dtype_2d():

assert result2.shape == (4, 1)
assert all(td._value == 0 for td in result2.ravel())


def test_concat_float_datetime64(using_array_manager):
Copy link
Member

Choose a reason for hiding this comment

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

Could you move this test to pandas/tests/reshape/concat/test_datetimes.py? After that this looks good

@liang3zy22
Copy link
Contributor Author

It seems that another numpy error in "Ubuntu / Numpy Dev(pull_request)".

>       warnings.warn("`product` is deprecated as of NumPy 1.25.0, and will be "
[134](https://github.com/pandas-dev/pandas/actions/runs/4379948504/jobs/7666450861#step:8:136)
                      "removed in NumPy 2.0. Please use `prod` instead.",
[135](https://github.com/pandas-dev/pandas/actions/runs/4379948504/jobs/7666450861#step:8:137)
                      DeprecationWarning, stacklevel=2)
[136](https://github.com/pandas-dev/pandas/actions/runs/4379948504/jobs/7666450861#step:8:138)
E       DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.

@mroeschke mroeschke added this to the 2.1 milestone Mar 10, 2023
@mroeschke mroeschke merged commit eb7f903 into pandas-dev:main Mar 10, 2023
@mroeschke
Copy link
Member

Thanks @liang3zy22 (that failure is unrelated)

@liang3zy22 liang3zy22 deleted the testconcatfunc branch March 11, 2023 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect dtype for concat with empty float and datetime columns
2 participants