You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in #10, the dot/period on the RHS of a formula is not currently supported in Patsy. Could you update the docs, in the Comparison to R section https://patsy.readthedocs.io/en/latest/R-comparison.html, to mention this difference? Dot on the RHS is used quite extensively in R — in fact, most basic examples are written with it — so this is definitely a difference people will notice.
The text was updated successfully, but these errors were encountered:
Here is some somewhat clunky code that can handle most of what the dot operator in R can do (albeit not as gracefully). I agree that the absence of '.' is a fairly large omission from the formula language.
`def dot(data_frame, omit=[]):
"""
Build a formula string by "summing" all entries except those on an 'omit
list'. This would typically include the name of the variable on the left
hand side of the equation.
This function is named for the 'dot' operator in R, where a formula given
as 'y ~ .' means "regress y on all other variables". The R dot operator
can also be used to specify interactions, as in y ~ .^2. To allow for
similar specifications, the return value of this function is wrapped in
paraentheses "()".
Args:
data_frame: The data frame from which to build the equation. A list or
array of column names is also acceptable.
omit: A list of names to omit.
Returns:
A string containing the list of names in data_frame, separated by '+'.
The return value begins with '(' and ends with ')' so that y~dot(data,
omit=["y"])**2 can be used to specify all 2-way interactions.
"""
vnames = [x for x in data_frame.columns if x not in omit]
ans = "(" + "+".join(x for x in vnames) + ")"
return ans
As discussed in #10, the dot/period on the RHS of a formula is not currently supported in Patsy. Could you update the docs, in the Comparison to R section https://patsy.readthedocs.io/en/latest/R-comparison.html, to mention this difference? Dot on the RHS is used quite extensively in R — in fact, most basic examples are written with it — so this is definitely a difference people will notice.
The text was updated successfully, but these errors were encountered: