Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)
But that behavior is specific to Jupyter and so it could similarly provide auto-complete or syntax highlighting for usage of `smf.ols(formula=...)`. Like PyCharm provides syntax highlighting for strings used as the `pattern` argument for the various functions of the `re` module. So if it's only for the sake of auto-complete or syntax highlighting, this is on the IDE and not on the language, in my opinion. On 24.02.20 17:48, David Mertz wrote:
I get auto-complete on column names in Pandas when I'm in Jupyter. But yes, I agree with you.
On Mon, Feb 24, 2020, 11:43 AM Dominik Vilsmeier <dominik.vilsmeier@gmx.de <mailto:dominik.vilsmeier@gmx.de>> wrote:
I don't see what's wrong with the status quo:
smf.ols(formula='Lottery ~ Literacy + Wealth + Region', data=df)
If I understand correctly you want to use instead:
smf.ols(formula=df.Lottery ~ df.Literacy + df.Wealth + df.Region)
Or since some people favor indexing over attribute access for column names:
smf.ols(formula=df['Lottery'] ~ df['Literacy'] + df['Wealth'] + df['Region'])
Both alternatives are much more verbose since you have to repeat the `df` part or even worse the brackets for indexing. In any case you need to type the column names that you would like to include and there's no auto-complete on column names that would help you typing it. So I don't see what's the benefit of the operator version.
In addition this requires Pandas to implement the modeling but there's much more to Pandas than just modeling so perhaps that better remains a separate project.
On 24.02.20 01:27, Aaron Hall via Python-ideas wrote: > I have no behavior for integers in mind. I would expect high-level libraries to want to implement behavior for it. > > - sympy > - pandas, numpy, sklearn, statsmodels > - other mathematically minded libraries (monadic bind or compose?) > > To do this we need a name. I like `__sim__`. Then we'll need `__rsim__` and `__isim__` for completeness. We need to make room for it in the grammar. Is it ok to give it the same priority of evaluation as `+` or `-`, or slightly higher? > > In the past we've made additions to the language when we've been parsing and evaluating strings. That's what we're currently doing in statsmodels right now because we lack the binary (in the sense of two-arguments) `~`. > > See: https://www.statsmodels.org/dev/example_formulas.html > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org <mailto:python-ideas@python.org> > To unsubscribe send an email to python-ideas-leave@python.org <mailto:python-ideas-leave@python.org> > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/JWC4HJ... > Code of Conduct: http://python.org/psf/codeofconduct/ _______________________________________________ Python-ideas mailing list -- python-ideas@python.org <mailto:python-ideas@python.org> To unsubscribe send an email to python-ideas-leave@python.org <mailto:python-ideas-leave@python.org> https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VQOYS4... Code of Conduct: http://python.org/psf/codeofconduct/
participants (1)
-
Dominik Vilsmeier