Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Use pandas, PyArrow, and Polars eager in the DataFrame docstring examples #1000

Closed
MarcoGorelli opened this issue Sep 19, 2024 · 7 comments · Fixed by #1733
Closed
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers, but anyone is welcome to submit a pull request!

Comments

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Sep 19, 2024

In the docstrings example in https://narwhals-dev.github.io/narwhals/api-reference/dataframe/, we always show the output for pandas and Polars

We should instead:

  • show pandas, Polars (eager), and Pyarrow
  • phrases such as "We can then pass either pandas or Polars:" should be rephrased to "We can then pass any supported library such as pandas, Polars, or PyArrow:"

If this is your first time submitting a pull request, please choose one function to start with, and only submit a pull request for that one function. You've got used to the process, feel free to submit changes for more functions together (e.g. in groups of 3-4 functions in the same PR)


Contributing guide: https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md

example PR: #1010

@MathiasHolmstrom
Copy link
Contributor

MathiasHolmstrom commented Sep 20, 2024

I can take a stab at making a PR for one of the functions (DataFrame to_pandas() )

@Jupetus
Copy link
Contributor

Jupetus commented Sep 20, 2024

I will try the DataFrame.to_csv()

@CarloLepelaars
Copy link
Contributor

CarloLepelaars commented Oct 17, 2024

I worked on Expr.mean in expr.py. If this looks good I could do the others in Expr.

PR: #1207

@CarloLepelaars
Copy link
Contributor

Glad that the doc update for Expr.mean went smooth. Can now also pick up the other functions in Expr.

@AlessandroMiola
Copy link
Contributor

In the docstrings example in https://narwhals-dev.github.io/narwhals/api-reference/dataframe/, we always show the output for pandas and Polars

We should instead:

  • show pandas, Polars (eager), and Pyarrow
  • phrases such as "We can then pass either pandas or Polars:" should be rephrased to "We can then pass any supported library such as pandas, Polars, or PyArrow:"

This is very much personal taste, but what would you think about rendering the different outputs via mkdocs-material content tabs? Something like the following

image
=== "pandas"
    ```python

    func(df_pd)
    ```
    Output:
    ```
        a     b
    0  24.5  74.5
    ```
=== "Polars (eager)"
    ```python

    func(df_pl)
    ```
    Output:
    ```
    shape: (1, 2)
    ┌──────┬──────┐
    │ a    ┆ b    │
    │ ---  ┆ ---  │
    │ f64  ┆ f64  │
    ╞══════╪══════╡
    │ 24.5 ┆ 74.5 │
    └──────┴──────┘
    ```
=== "PyArrow"
    ```python

    func(df_pa)
    ```
    Output:
    ```
    pyarrow.Table
    a: double
    b: double
    ----
    a: [[24.5]]
    b: [[74.5]]
    ```

@FBruzzesi
Copy link
Member

This is very much personal taste, but what would you think about rendering the different outputs via mkdocs-material content tabs? Something like the following

@AlessandroMiola I like the tabbed output much more as well, but I think the issue was compatibility with doctest. If you manage to figure out how to have both, I am absolutely happy to move to such output rendering

@AlessandroMiola
Copy link
Contributor

This is very much personal taste, but what would you think about rendering the different outputs via mkdocs-material content tabs? Something like the following

@AlessandroMiola I like the tabbed output much more as well, but I think the issue was compatibility with doctest. If you manage to figure out how to have both, I am absolutely happy to move to such output rendering

Ahh, right! I see, thanks @FBruzzesi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers, but anyone is welcome to submit a pull request!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants