narwhals-dev / narwhals

Lightweight and extensible compatibility layer between dataframe libraries!
https://narwhals-dev.github.io/narwhals/
MIT License
568 stars 88 forks source link

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

Open MarcoGorelli opened 1 month ago

MarcoGorelli commented 1 month ago

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:

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: https://github.com/narwhals-dev/narwhals/pull/1010

MathiasHolmstrom commented 1 month ago

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

Jupetus commented 1 month ago

I will try the DataFrame.to_csv()

CarloLepelaars commented 3 weeks ago

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

PR: #1207

CarloLepelaars commented 3 weeks ago

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

AlessandroMiola commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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