Skip to content

DOC: Fix docstring for assert_frame_equal examples #26003

Closed
@BryanCutler

Description

@BryanCutler

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions