File tree 2 files changed +12
-9
lines changed
packages/python/plotly/plotly
tests/test_optional/test_px
2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -1308,14 +1308,17 @@ def build_dataframe(args, constructor):
1308
1308
df_provided = args ["data_frame" ] is not None
1309
1309
if df_provided and not isinstance (args ["data_frame" ], pd .DataFrame ):
1310
1310
if hasattr (args ["data_frame" ], "__dataframe__" ):
1311
- # Pandas does not implement a `from_dataframe` yet
1312
- # $ wget https://raw.githubusercontent.com/data-apis/dataframe-api/main/protocol/pandas_implementation.py
1313
- # $ export PYTHONPATH=`pwd`
1314
- import pandas_implementation
1315
-
1316
- args ["data_frame" ] = pandas_implementation .from_dataframe (
1317
- args ["data_frame" ]
1318
- )
1311
+ try :
1312
+ import pandas .api .interchange
1313
+ except ModuleNotFoundError :
1314
+ raise NotImplementedError (
1315
+ "The dataframe you provided supports the dataframe interchange"
1316
+ "protocol, "
1317
+ "but pandas 1.5.0 or greater is required to consume it."
1318
+ )
1319
+ df_not_pandas = args ["data_frame" ]
1320
+ df_pandas = pandas .api .interchange .from_dataframe (df_not_pandas )
1321
+ args ["data_frame" ] = df_pandas
1319
1322
else :
1320
1323
args ["data_frame" ] = pd .DataFrame (args ["data_frame" ])
1321
1324
df_input = args ["data_frame" ]
Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ def test_build_df_with_index():
236
236
def test_build_df_protocol ():
237
237
import vaex
238
238
239
- # take out the 'species' columns since the vaex implementation does not cover strings yet
239
+ # take out the 'species' columns since there are still some issues with strings
240
240
iris_pandas = px .data .iris ()[["petal_width" , "sepal_length" ]]
241
241
iris_vaex = vaex .from_pandas (iris_pandas )
242
242
args = dict (data_frame = iris_vaex , x = "petal_width" , y = "sepal_length" )
You can’t perform that action at this time.
0 commit comments