Skip to content

BUG: very minor error I can't understand but was easily fixed. #53204

@markingt0n

Description

@markingt0n

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

df = [*things*]

df = df[df['price'] > 0]

Issue Description

TypeError: '>' not supported between instances of 'str' and 'int'

Expected Behavior

Where it happened and why is the only question. Obviously, you could assume I was trying to use a maths operator on a string, but that shouldn't be what happened.

I ran code containing the above in google colabs, worked fine. it was only in vscode the error came up. The data was via an api call, the same data, some 20 minutes after it was 1st called.

I fixed it with this, df['price'] = pd.to_numeric(df['price'], errors='coerce') , easy, no problems.

The code was copy pasted, 1:1 no changes. I imagine colab may use an older version? Anyway, very minor issue but a bit odd. For whatever reason different versions have interpreted the exact same data as a different type.

Installed Versions

Latest stable version as of 11/05/2023 on vscode
Whatever Colab are using.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugClosing CandidateMay be closeable, needs more eyeballsNeeds InfoClarification about behavior needed to assess issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions