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
nyaaaaaaaaaa if N/A is NaN that is normal I think
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
that is admittedly unintuitive if you’re not aware of it though
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
i’m 90% sure that the most R most people in industry actually know is the command that lets you use python
NYAAAAAAAAAA PYTHON BEST LANGUAGE
(it does have the same thing with nans tho)
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.
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.
do you mean at least 1 of 3
or strictly 1 in 3
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
at least. but in practice it will never show up in more than 1
does N/A == N/A return N/A?? instead of False???
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
R
nyaaaaaaa I realize
but I was wondering if there was a way to make it clean with shortcircuiting
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
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)
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).