Skip to content

DOC: Fix docstring for assert_frame_equal examples #26003

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

Closed
BryanCutler opened this issue Apr 5, 2019 · 0 comments · Fixed by #26004
Closed

DOC: Fix docstring for assert_frame_equal examples #26003

BryanCutler opened this issue Apr 5, 2019 · 0 comments · Fixed by #26004
Labels
Milestone

Comments

@BryanCutler
Copy link
Contributor

Problem description

The docstring for assert_frame_equals examples is not formatted correctly.

The example section of the docstring for pandas.util.testing.assert_frame_equal is not formatted correctly and causes them to be displayed wrong. There needs to be some added newlines to separate the code blocks.

This example shows comparing two DataFrames that are equal but with columns of differing dtypes.

>>> from pandas.util.testing import assert_frame_equal
>>> df1 = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
>>> df2 = pd.DataFrame({'a': [1, 2], 'b': [3.0, 4.0]})

df1 equals itself. >>> assert_frame_equal(df1, df1)

df1 differs from df2 as column ‘b’ is of a different type. >>> assert_frame_equal(df1, df2) Traceback (most recent call last): AssertionError: Attributes are different

Attribute “dtype” are different [left]: int64 [right]: float64

Ignore differing dtypes in columns with check_dtype. >>> assert_frame_equal(df1, df2, check_dtype=False)

see https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.testing.assert_frame_equal.html#pandas-testing-assert-frame-equal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants