Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Last answered:

18 Jul 2024

Posted on:

18 Jul 2024

0

Resolved: Missing value in a list

is there another faster way to know the missing value 20 beside using the (sorted) function,

cause if  I have a longer list that might take a while to spot that number

1 answers ( 1 marked as helpful)
Instructor
Posted on:

18 Jul 2024

0

Hi Doaa!
Thanks for reaching out.


Yes, you can use the set difference method to find the missing value quickly. Here's a short example:

all_values = set(range(1, 29))  # Assuming 1 to 28 are possible values
missing_values = all_values - set(df['Reason for Absence'].unique())
print(missing_values)

The answer will be the set of missing values from your data. If the missing value is 20, the output will be:

{20}


Hope this helps.
Best,
Tsvetelin

Submit an answer