-
Notifications
You must be signed in to change notification settings - Fork 175
Closed
Labels
enhancementNew feature or requestNew feature or requesthigh priorityYour PR will be reviewed very quickly if you address thisYour PR will be reviewed very quickly if you address this
Description
Currently I often have the following code:
df_nw = nw.from_native(df)
is_pandas = nw.dependencies.is_pandas_dataframe(df)
.....
if is_pandas:
do something different
......
What is difficult about this, is that I need to keep track of is_pandas variables throughout the code, send them in subfunctions, etc. If I have multiple DataFrames, I have multiple such is_pandas variables. Ideally, I'd be able to do something such as:
is_pandas = df_nw.is_native_pandas
i.e., having whether the underlying dataframe is pandas or not simply as a boolean attribute of the Narwhals DataFrame. That would allow me to use df_nw everywhere without requiring the auxiliary variables everywhere or first converting to native.
Of course, I know I can also do this everywhere: nw.dependencies.is_pandas_dataframe(df_nw.to_native())) but that feels convoluted.
What is the cleanest way to do this?
MarcoGorelli
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthigh priorityYour PR will be reviewed very quickly if you address thisYour PR will be reviewed very quickly if you address this