File tree 1 file changed +11
-1
lines changed
packages/python/plotly/plotly/express
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1314,7 +1314,17 @@ def build_dataframe(args, constructor):
1314
1314
import pandas .api .interchange
1315
1315
1316
1316
df_not_pandas = args ["data_frame" ]
1317
- df_pandas = pandas .api .interchange .from_dataframe (df_not_pandas )
1317
+ try :
1318
+ df_pandas = pandas .api .interchange .from_dataframe (df_not_pandas )
1319
+ except (ImportError , NotImplementedError ) as exc :
1320
+ # temporary workaround; developers of third-party libraries themselves
1321
+ # should try a different implementation, if available. For example:
1322
+ # def __dataframe__(self, ...):
1323
+ # if not some_condition:
1324
+ # self.to_pandas(...)
1325
+ if not hasattr (df_not_pandas , "to_pandas" ):
1326
+ raise exc
1327
+ df_not_pandas .to_pandas ()
1318
1328
args ["data_frame" ] = df_pandas
1319
1329
elif hasattr (args ["data_frame" ], "to_pandas" ):
1320
1330
args ["data_frame" ] = args ["data_frame" ].to_pandas ()
You can’t perform that action at this time.
0 commit comments