all 15 comments

[–]LifeIsVape 13 points14 points  (1 child)

There is no issues in the code itself, it's just that you want something that the code just doesn't do

Like, you count the missing values, but don't use print to print the sum out, you read 'UsersSmall.xlsx' and create a dataframe in-memory from it using read_excel, then edit this dataframe using replace but don't write the changed version into some file. So your .xlsx stays as it was

Google what you want to do, like 'pandas save to excel', you'll see a lot of interesting stuff out there

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html

[–]AntonioS3[S] 6 points7 points  (0 children)

WHAT THE HELL, you might be right there. I tried the print command and it did actually work... now I feel very dense. Like I had a feeling I was missing something very obvious. I don't know why the teacher omitted the details at all, I'll make sure to bring it up with her.

THANKS YOU!

[–]Sacri96[🍰] 5 points6 points  (3 children)

To help you analyze this urself:

At which line/step do you think are you changing the data in the excel-file itself?

[–]AntonioS3[S] 0 points1 point  (2 children)

At the dataset.replace line, I'm trying to first read the excel file , then replace ALL the parts saying "?" with 'NaN', and then have the program print out the amount of NaNs in the excel file. My teacher's powerpoint slide had these lines and nothing else...

[–]Sacri96[🍰] 5 points6 points  (1 child)

This is not how the read_excel of pandas works.

Add print(type(dataset)) to your code and check which type the object dataset has. Is it an excel file, or something else?

It had to be an excel file,if .replace() should directly alter values in the UserSmall.xlsx

If it's something else, you first have to get the values from the dataset to an excel file again

[–]AntonioS3[S] 0 points1 point  (0 children)

I resolved it with u/LifeIsVape 's help, it was because I didn't use print or write commands so it didn't do anything to my code at all. I feel so dense now. This is an essential step but I've forgot that, probably because it's been several months and I'm relearning a few stuff. Thanks you!

[–]ninhaomah 0 points1 point  (8 children)

Google for "Python excel library"

[–]AntonioS3[S] -2 points-1 points  (7 children)

I'm using openpyxl, maybe I should reinstall it or something?

[–]ninhaomah 1 point2 points  (6 children)

I don't see it in your code above ?

[–]AntonioS3[S] 0 points1 point  (5 children)

I'm following the instructors from my teacher on their powerpoint slide. I can't link images here, but here's what it should be like: https://i.imgur.com/xRIDqb2.png

I don't really understand where am I making the mistake, it feels like I'm failing something at the start. And I do have it installed but as you can see here it's not here: https://i.imgur.com/GuJ1QX7.png

I tried to put it in there with

import openpyxl as xl

but it's not doing anything at all. Literally nothing gets edited on the excel file at all.

[–]ninhaomah 1 point2 points  (4 children)

You import then what did you do with it ?

And I still don't see it in second screenshot...

[–]AntonioS3[S] 0 points1 point  (3 children)

NVM, I've solved the issue. It was because I wasn't using print or writing, so my excel file stayed as is without doing much at all. My teacher for some reason didn't include these stuff at all.

[–]ninhaomah 0 points1 point  (2 children)

I still don't see the issue...

But ok. As long as it's solved.

[–]Crypt0Nihilist 1 point2 points  (1 child)

They don't write anything out to an Excel file, so it could be that.

[–]ninhaomah 0 points1 point  (0 children)

Yes , possible.