narwhals-dev / narwhals

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

docs: add docstring examples for dtypes #1077

Open MarcoGorelli opened 2 days ago

MarcoGorelli commented 2 days ago

The dtypes don't currently have docstrings https://narwhals-dev.github.io/narwhals/api-reference/dtypes/

it would be good to add a docstring to each, perhaps even with an example of how to end up with that dtype pandas/polars/pyarrow

anopsy commented 2 days ago

I'll take that. Just found out that Polars documentation doesn't show examples for dtypes. And Pandas documentation has examples that look like:

>>>pd.BooleanDtype()
BooleanDtype
anopsy commented 1 day ago

hey @MarcoGorelli, I'd like to clarify what do you mean by "example how to end up with that dtype", do you mean - first using cast and then checking the series dtype, or just checking the dtype of series or a third secret thing? Btw do we want to implement Dataframe.dtypes ?

MarcoGorelli commented 1 day ago

i think any operation which produces that dtype is probably fine...e..g for boolean: nw.from_native(pd.Series([True, True, False]), series_only=True).dtype produces nw.Boolean

Dataframe.dtypes

not sure, there's already DataFrame.schema

anopsy commented 1 day ago

Thank you, that helps a lot!