Skip to content
Advertisement

Tag: r

groupby weighted average and sum in pandas dataframe

I have a dataframe: I need a sum of adjusted_lots , price which is weighted average , of price and adjusted_lots , grouped by all the other columns , ie. grouped by (contract, month , year and buys) Similar solution on R was achieved by following code, using dplyr, however unable to do the same in pandas. is the same

plyr or dplyr in Python

This is more of a conceptual question, I do not have a specific problem. I am learning python for data analysis, but I am very familiar with R – one of the great things about R is plyr (and of course ggplot2) and even better dplyr. Pandas of course has split-apply as well however in R I can do things

auto.arima() equivalent for python

I am trying to predict weekly sales using ARMA ARIMA models. I could not find a function for tuning the order(p,d,q) in statsmodels. Currently R has a function forecast::auto.arima() which will tune the (p,d,q) parameters. How do I go about choosing the right order for my model? Are there any libraries available in python for this purpose? Answer You can

Circular shift of vector (equivalent to numpy.roll)

I have a vector: And I’d like to do something like: Is there a function like that in R? I’ve been googling around, but “R Roll” mostly gives me pages about Spanish pronunciation. Answer How about using head and tail… One cool thing about using head and tail… you get a reverse roll with negative n, e.g.

Embed R code in python

I need to make computations in a python program, and I would prefer to make some of them in R. Is it possible to embed R code in python ? Answer You should take a look at rpy (link to documentation here). This allows you to do: And then you can use the object called r to do computations just

Advertisement