These are chat archives for FreeCodeCamp/DataScience
discussion on how we can use statistical methods to measure and improve the efficacy of http://freeCodeCamp.com
Question for pandas/python. is there a way to drop rows with all 0s in the columns EXCEPT for the index? i found this link below for all columns
@Rhistina how was at the end with the model? (Wasn't you who made a question last time about a regression model?)
About your question above, not sure if I understand your question.
drop rows with all 0s in the columns
Is this about dropping the column or the row? Or do you mean a row full of 0s that must be dropped? Or is a row of 0s but the index?
If the last, I don't think the operation will look at the index if from
pandas. If so, you might be applying an operation over a
pandas object from another library, likely
df[df.values.sum(axis=1) != 0]
anyis correct by keeping all those rows with at least one value different to 0. So it is a good alternative if that is what you want.
>>> df col1 col2 col3 col4 0 1 2 3 4 1 0 0 0 0 2 1 -1 0 0 >>> df[(df != 0).any(axis=1)] col1 col2 col3 col4 0 1 2 3 4 2 1 -1 0 0 >>> df[df.values.sum(axis=1) != 0] col1 col2 col3 col4 0 1 2 3 4
(df != 0).any(axis=1)for this
Sometimes I explore data in Kaggle and people trend to select one or another. By working in Jupyter I can cp some scripts from both and test them in the same place.
But yeah... I am also very rusty now with R. @erictleung is very proficient in R. I have seen him writing scripts in R from the top of his head, without looking at references.
pyrl or something like that? It is a different syntax I am not used to.
Personally, I usually feel frustrated when programmers embed sub-languages within an existing one (exception, JQuery). Even if it helps better, it is like having to learn everything again.
plyr. It is a nice R package, really nice. But it is written in a way that cause a certain cultural shock at first.
plyris becoming more the rule in R scripting than the exception.
But yeah, @Rhistina : I must admit that although is nice for the coder to be able to write in different languages, it is not nice when it comes to maintenance and all that stuff.
Somehow the reason why many people have been enjoying the JS stack, I guess.
People going to see a film. "The Square", an Swedish film with an Italian friend. Just a day after Italy lost for the first time their place in the Soccer World Cup to... Sweden!!!
For them not going to the World Cup is, like put in several news, the Apocalypse, End of World, bla bla bla. My friend is saying he is planning to boycott the film... Still going though.
See you around!
mutate_each()in one code and it says that it is deprecated and you should use
mutate_all()or something similar.
> mtcars %>% mutate_each(function(x) x - 3) `mutate_each()` is deprecated. Use `mutate_all()`, `mutate_at()` or `mutate_if()` instead. To map `funs` over all variables, use `mutate_all()` Error: is_fun_list(funs) is not TRUE > mtcars %>% mutate_all(function(x) x - 3) mpg cyl disp hp drat wt qsec vs am gear carb 1 18.0 3 157.0 107 0.90 -0.380 13.46 -3 -2 1 1 2 18.0 3 157.0 107 0.90 -0.125 14.02 -3 -2 1 1 3 19.8 1 105.0 90 0.85 -0.680 15.61 -2 -2 1 -2 4 18.4 3 255.0 107 0.08 0.215 16.44 -2 -3 0 -2 5 15.7 5 357.0 172 0.15 0.440 14.02 -3 -3 0 -1 ...