-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add support for dataframes that have toPandas
method
#4300
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 Nice and easy 😎
Co-authored-by: Alex Johnson <johnson.alex.c@gmail.com>
FWIW, |
might_be_a_converter = [
method for method in dir(df_not_pandas)
if 'to' in method.lower()
and 'pandas' in method.lower()
and method.lower().index('to') < method.lower().index('pandas')
]
if might_be_a_converter:
args["data_frame"] = getattr(df_not_pandas, might_be_a_converter[0])() 🙃 probably not, but we could add |
if not ( | ||
hasattr(df_not_pandas, "to_pandas") | ||
or hasattr(df_not_pandas, "toPandas") | ||
or hasattr(df_not_pandas, "to_pandas_df") | ||
): | ||
raise exc | ||
args["data_frame"] = df_not_pandas.to_pandas() | ||
if hasattr(df_not_pandas, "toPandas"): | ||
args["data_frame"] = df_not_pandas.toPandas() | ||
elif hasattr(df_not_pandas, "to_pandas_df"): | ||
args["data_frame"] = df_not_pandas.to_pandas_df() | ||
else: | ||
args["data_frame"] = df_not_pandas.to_pandas() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but it would be a bit cleaner to invert this:
if hasattr(df_not_pandas, "toPandas"):
args["data_frame"] = df_not_pandas.toPandas()
elif hasattr(df_not_pandas, "to_pandas_df"):
args["data_frame"] = df_not_pandas.to_pandas_df()
elif hasattr(df_not_pandas, "to_pandas"):
args["data_frame"] = df_not_pandas.to_pandas()
else:
raise exc
Add support for dataframes that have
toPandas
methodCode PR
plotly.graph_objects
, my modifications concern thecodegen
files and not generated files.modified existing tests.
new tutorial notebook (please see the doc checklist as well).