Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dropNa not working #637

Open
jaycoolslm opened this issue Mar 31, 2024 · 3 comments
Open

dropNa not working #637

jaycoolslm opened this issue Mar 31, 2024 · 3 comments

Comments

@jaycoolslm
Copy link

jaycoolslm commented Mar 31, 2024

I am importing an excel file which contains an undefined field:

// read the excel file
  let df = (await dfd.readExcel(local_xcel)) as DataFrame;
  if (test) {
    df = df.head(testAmount);
  }
  console.log("Initial Dataframe");
  df.iloc({ rows: ["15:18"] }).print();

  console.log(df.shape);

  let df_drop = df.dropNa({ axis: 1 });
  df_drop
    .iloc({ rows: ["15:18"] })
    .isNa()
    .print();
  console.log(df_drop.shape);

this code is not removing the undefined row, even though it is identifying it as undefined when using the .isNa() mask

@aniketkumar7
Copy link

aniketkumar7 commented Apr 4, 2024

I think this might works :

The line df = df.dropna({ axis: 0, how: 'any' }) will remove any rows that have at least one undefined value.

  1. The axis: 0 parameter specifies that we’re dropping rows.
  2. The how: 'any' parameter ensures that any row containing at least one undefined value will be dropped.

Can I contribute to it if this works?

@jaycoolslm
Copy link
Author

Hi @aniketkumar7,

I get this error when trying that how property

Object literal may only specify known properties, and 'how' does not exist in type '{ axis: 0 | 1; inplace?: boolean | undefined; }'.

doesn't seem to be implemented

@aniketkumar7
Copy link

Yes, you are right, It seems that the "how" property is not available in the version of DataFrame.

Try after removing the how property and directly applied df.dropna({ axis: 0 }) to drop rows with any null value. I think this should work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants