Skip to content

"Cannot calculate mean, unexpected type of argument" when data has nulls #335

Closed
@codeheart09

Description

@codeheart09

When I call .describe() on a data frame with some null values, I get this error:

return new TypeError('Cannot calculate ' + fnName + ', unexpected type of argument' + details);
           ^

TypeError: Cannot calculate mean, unexpected type of argument (type: null, value: null)

You can check the dataset here: https://raw.githubusercontent.com/ageron/handson-ml2/master/datasets/housing/housing.tgz

Here is the code I have:

// ... after downloading and extracting the file
const dataFrame = await dfd.read_csv(RAW_DATA_DIR + '/housing.csv');
dataFrame.describe().print();

And if I console.log the dataframe itself, the data seem to be imported correctly.

// ...
'$data': [
    [
      -122.23, 37.88,
      41,      880,
      129,     322,
      126,     8.3252,
      452600,  'NEAR BAY'
    ],
// ..
'$columns': [
    'longitude',
    'latitude',
    'housing_median_age',
    'total_rooms',
    'total_bedrooms',
    'population',
    'households',
    'median_income',
    'median_house_value',
    'ocean_proximity'
  ]

But it indeed has some null values in some rows.

Shouldn't the lib skip the null values? Or I'm missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions