Skip to content

Operator "-" not supported for types "DataFrame" and "Series[Dtype@mean] #2139

@mhlg

Description

@mhlg
  • Language Server version: v2021.11.2
  • OS and version: macOS 10.15.7
  • Python version: 3.8.2

Actual behaviour

import numpy as np
import pandas as pd
columns = ['A']
df = pd.DataFrame(np.random.randint(0, 100, size=(100, 1)), columns=columns)

# Normalization
df = (df - df.mean()) / df.std()

Operator "-" not supported for types "DataFrame" and "Series[Dtype@mean]"
Operator "-" not supported for types "DataFrame" and "Series[Dtype@mean]"
PylancereportGeneralTypeIssues


# Denormalization
epsilon = 1e-100
coefficients = pd.DataFrame()
coefficients['mean'] = df.loc[:, columns].mean()
coefficients['std'] = df.loc[:, columns].std() + epsilon
coefficients = coefficients.T

column = 'A'
std = coefficients.loc['std', column]
mean = coefficients.loc['mean', column]

df[column] = X[column] * std + mean

Operator "*" not supported for types "Series[Dtype@__getitem__]" and "Scalar"
PylancereportGeneralTypeIssues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtypestubIssue relating to our bundled type stubs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions