Git Product home page Git Product logo

Comments (4)

matthewwardrop avatar matthewwardrop commented on July 19, 2024 1

Hi!

Thanks for writing in to report the issue. Just like in a Python expression, - has special meaning and cannot be used without some kind of quoting. For example, in python b-foo means b minus foo. In a formula it means b set difference foo.

If you want to use the column b-foo, then just quote the column name. You can do this using back-ticks.

import pandas
from formulaic import model_matrix

df = pandas.DataFrame({
    'y': [0, 1, 2],
    'a': ['A', 'B', 'C'],
    'b-foo': [0.3, 0.1, 0.2],
})

y, X = model_matrix("y ~ a + `b-foo`", df)

This outputs the desired module matrix :).

You can learn more about the formula grammar here.

from formulaic.

matthewwardrop avatar matthewwardrop commented on July 19, 2024 1

It is there (see third row in table within screenshot below):

image

But perhaps not called out as much as it should be. The documentation will definitely be enriched in the future with how-to guides/etc once I find some time!

from formulaic.

erikr avatar erikr commented on July 19, 2024

Thanks, this answers my question and resolves the issue. Did I miss it, or does the documentation not include this info?

from formulaic.

erikr avatar erikr commented on July 19, 2024

Thanks for helping me find that in the documentation! The table format is helpful.

from formulaic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.