Skip to content

Add support for python-polars #1868

Open

Description

@edoaltamura

Besides the use of pandas, it would be great to add support for the polars Python interface: https://github.com/pola-rs/polars.
Polars has very similar functionalities to Pandas, but uses a Rust backend that significantly speeds up operations compared to Pandas.

Activity

  1. ValueRaider commented on Feb 24, 2024

    @ValueRaider
    Collaborator

    I like what I hear about Polars, but great care will be needed to avoid upsetting user base.

    Is there another popular package that migrated that we can learn from?

  2. edoaltamura commented on Feb 29, 2024

    @edoaltamura
    Author

    I can't think of projects that started in Pandas and then transitioned, and I do agree that care is needed when migrating foundational dependencies. This Medium article can give a flavor of what a 'translation' might look like.

    In my view, simply translating can give some speed up over Pandas, but some more thinking is required to make the most of the lazy execution in Polars, which would give an extra boost.

  3. gaborschulz commented on Oct 16, 2024

    @gaborschulz

    Also agree with being careful about the migration. In my opinion, the most efficient way to do so would be to transition to using narwhals (https://github.com/narwhals-dev/narwhals) as this is becoming the de-facto standard for supporting multiple dataframe libraries.

  4. FBruzzesi commented on Mar 25, 2025

    @FBruzzesi

    Hey everyone! I am one of developers contributing to Narwhals!

    yfinance is a very interesting project, thanks for mentioning Narwhals here @gaborschulz

    I can't think of projects that started in Pandas and then transitioned

    @edoaltamura this might have been true at the time, but in the last 6-8 months a few (big?) projects transitioned to a dataframe agnostic approach using Narwhals (see ecosystem).

    I am not sure that Narwhals has all the functionality to let yfinance make such transition as well, but our approach has been very pragmatic in adding features whenever a use case presents itself, and we currently have a weekly release cycle 😁

    If there is still interest in this, I can start taking a look at the internals in the next future 😇

  5. gaborschulz commented on Apr 2, 2025

    @gaborschulz

    I‘m happy to join and look into it together, @FBruzzesi

  6. FBruzzesi commented on Apr 3, 2025

    @FBruzzesi

    Hi @gaborschulz - the main/only real blocker I see is that we don't support the equivalent of polars.DataFrame.group_by_dynamic - which is the pandas equivalent of resample.

    Aside that, from a design point of view, my understand is that everything revolves around the Ticker class (from a user point of view), and we could either:

    • Add a parameter, such as return_type in the initialization method, defaulting to pandas (we did something similar in plotly.express.datasets)
    • Or have some global config to set that
  7. ValueRaider commented on Apr 3, 2025

    @ValueRaider
    Collaborator

    Or have some global config to set that

    Preferred option. There's plans to do config properly, but until then you can shove something into data.py.

  8. FBruzzesi commented on May 12, 2025

    @FBruzzesi

    Tiny update on:

    the main/only real blocker I see is that we don't support the equivalent of polars.DataFrame.group_by_dynamic - which is the pandas equivalent of resample.

    after the development of dt.truncate and allowing expressions as group by keys, it should be enough to support the operations required in yfinance via:

    (
        frame
        .group_by(nw.col('date').dt.truncate('1mo'))
        .agg(nw.col('price').mean())
    )

    (From narwhals#2532 comment)

  9. added a commit that references this issue on May 18, 2026
    5353ffa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions