Attention: FYI, I just copied code for "Missing Numbers" in Python from Franklin. I also observe your code from tibor Santa. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Attention: FYI, I just copied code for "Missing Numbers" in Python from Franklin. I also observe your code from tibor Santa.

This must be conducted to enable me continue my lesson in data science python, since my own code doesn't pass the rest 2 of 5 test case, number 3,4 or test Cases no. 4,5 eventhough I got exactly the same output as required. Thank you class.

6th May 2023, 6:45 AM
Oliver Pasaribu
9 Answers
+ 6
I'm sorry, are you reporting something or asking something? If you'd like someone to help you, can you please create a codebit, copy in the task and your code attempt and attach it here? Read the following: https://code.sololearn.com/Wek0V1MyIR2r/?ref=app
6th May 2023, 7:28 AM
Ausgrindtube
Ausgrindtube - avatar
+ 4
Again, if you don't actually show your code, then we can't help you. Maybe you think the difference is not significant, but it will not help you learn anything, if you just blindly copy some random stuff and you pass the test without understanding why. Tracking down and finding bugs is an important part of programming. On the other hand, ignoring bugs usually leads to disaster.
6th May 2023, 2:20 PM
Tibor Santa
Tibor Santa - avatar
+ 4
NaN is a very special kind of value, and Numpy has a couple of built in methods to deal with it. Sticking with your imperative code, if you wish to update each value one by one in a loop, use np.isnan() for checking NaN values. for i in range(0, len(lst_arr)): if np.isnan(lst_arr[i]): lst_arr[i] = avg Or you can use a special replace function built into numpy: lst_arr = np.nan_to_num(lst_arr, nan=avg)
7th May 2023, 6:14 AM
Tibor Santa
Tibor Santa - avatar
+ 2
I am not sure how I got involved in this :) Anyway, if you post your code attempt that does not pass the test, we can help you by analysing and understanding why it's wrong, where the flaw is in your code.
6th May 2023, 2:00 PM
Tibor Santa
Tibor Santa - avatar
+ 2
Yes, sure. I am working with handling missing number in a python list. Theoretically, if there is a missing data value, or corrupted data value, we must change this corrupted value or nan or NP.NaN value with its mean value. I have suceeded calculate mean value using np.mean(list_arr) or using np.nanmean(list_arr) if there is a nan , "nan" or np.NaN value rounded to one decimal place as required. But I stuck on the next final step : replacing nan in numpy array with it mean value. I use for loop: avg = np.nanmean(lst_arr) for i in range(len(lst_arr)): if arr[i] == "nan" : # or if arr[i] == 'nan' ?? arr[i] = avg print(lst_arr) Output: [3.0, 4.0, 5.0, nan] #why nan is still present, not replacel by its mean stored in avg or np.nanmean(lst_arr)? https://code.sololearn.com/cKcX1phh7O3j/?ref=app
7th May 2023, 4:42 AM
Oliver Pasaribu
+ 2
Thanks Tibor Santa and friends. I Will try your suggestion. I have read that there is a way provided by python numpy: x = https://code.sololearn.com/cKcX1phh7O3j/?ref=app
7th May 2023, 10:04 AM
Oliver Pasaribu
+ 1
Please explain what are you trying to say??
6th May 2023, 8:02 AM
Hasnain [ACTIVE CHALLENGER]
Hasnain [ACTIVE CHALLENGER] - avatar
0
If you can't pass the test on your own, so you just copy somebody else's work ... well, I'd like to say that's bad, but I guess it's pretty good practice for the real world. How many programmers actually ever look under the hood of their imports? Still, just remember that this is no-stakes learning, so you're only cheating yourself.
6th May 2023, 12:51 PM
Orin Cook
Orin Cook - avatar
0
Well just for your information. I have observe that this is a recurring event, or periodic event at the end of each chapter, when doing code challenges or something, after Quiz of each chapter. I also realized that this, at final point required or eventually make a public opinion that I could not finish all works by myself as required. But I do compare my own code to all of your code. It seems that there is no significant different between mine and yours. I eventually have the exactly same output as required. But I still don't know why I can't pass all given test cases. Thank you very much.
6th May 2023, 2:16 PM
Oliver Pasaribu