dropNa not working
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
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.
- The axis: 0 parameter specifies that we’re dropping rows.
- 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?
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
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.