Skip to content

STY/TST: what standard to follow to import top-level objects in tests #33203

Open
@jorisvandenbossche

Description

@jorisvandenbossche

So this discussion regularly comes up (latest one being #33184), so let's try to decide which one of the two we prefer.

In test code, do we do:

from pandas import Series
...
Series(...)

or

import pandas as pd
...
pd.Series(..)

Personally, I prefer the second, and from recent discussions I have the impression @WillAyd and @datapythonista do as well (is that correct?)

To be clear: consistency within a single file is most important (so not mixing Series and pd.Series in a single file).
But when someone does a PR to fix such inconsistencies in a file, it would be good if there is agreement on whether such a PR should replace pd.Series with Series or rather replace Series with pd.Series.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code StyleCode style, linting, code_checksNeeds DiscussionRequires discussion from core team before further actionTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions