About the Rules & Moderation category (Part 1)

all i ask is to be able to replace the NAs in a column with 0s. but you can’t use the command that lets you replace values on a case by case basis because NA doesn’t equal NA. R should be thrown in a fire

1 Like

nyaaaaaaaaaa if N/A is NaN that is normal I think

1 Like

maybe they should consider not having this be the normal for the FUCKING DATA SCIENCE LANGUAGE WHERE YOU WILL OFTEN WANT TO REPLACE NA, ESPECIALLY EN MASSE

1 Like

that is admittedly unintuitive if you’re not aware of it though

1 Like

you’re allowed to take creative liberties with cs rules because you’re designing a new language specifically to be more useful in data science. that’s the point of designing a new language

1 Like

i’m 90% sure that the most R most people in industry actually know is the command that lets you use python

2 Likes

NYAAAAAAAAAA PYTHON BEST LANGUAGE

1 Like

(it does have the same thing with nans tho)

1 Like

note: the NA thing would not be a problem if the ifelse didn’t spit out NA upon encountering one (1) measly NA in my or statement.

1 Like

i just want to make a command that if a specific string shows up in 1 of 3 columns i get a 1 in my new column, and otherwise i get a 0. this is a simple ifelse… until you account for the fact that if that string isn’t in any of the columns and NA is it gives you NA. war.

1 Like

do you mean at least 1 of 3
or strictly 1 in 3

1 Like

something something python or also gives you the last value if all the other ones are false and the third column is mostly NA. i don’t care. it’s the data science language be useful for me

1 Like

at least. but in practice it will never show up in more than 1

1 Like

does N/A == N/A return N/A?? instead of False???

1 Like

you don’t have to do this work btw. since i already did it and just found the scuffed command to after the fact change the NAs to 0’s. which is very dumb

1 Like

R

1 Like

nyaaaaaaa I realize
but I was wondering if there was a way to make it clean with shortcircuiting

1 Like

this is when an AND or OR statement already knows the result (because the first condition was FALSE for AND or TRUE for OR), so it doesn’t evaluate the second condition at all

1 Like

besides speeding up the code, it’s useful for clean null-checks

ex:
if (obj is not None and obj.attribute_name > 1) isn’t going to give you an error if obj is None, because if obj is None the second part is never evaluated (putting the conditions the other way around would give the error)

1 Like

fun fact: the command that lets you change column values en masse is also dumb! because it also forces you to include even values you don’t plan on changing, just to assert that they are in fact the same. and anything you miss becomes NA (which, of course, you can’t change with that command because NA != NA).

1 Like