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 @@ -1304,14 +1304,17 @@ def build_dataframe(args, constructor):
1304
1304
df_provided = args ["data_frame" ] is not None
1305
1305
if df_provided and not isinstance (args ["data_frame" ], pd .DataFrame ):
1306
1306
if hasattr (args ["data_frame" ], "__dataframe__" ):
1307
- # Pandas does not implement a `from_dataframe` yet
1308
- # $ wget https://raw.githubusercontent.com/data-apis/dataframe-api/main/protocol/pandas_implementation.py
1309
- # $ export PYTHONPATH=`pwd`
1310
- import pandas_implementation
1311
-
1312
- args ["data_frame" ] = pandas_implementation .from_dataframe (
1313
- args ["data_frame" ]
1314
- )
1307
+ try :
1308
+ import pandas .api .interchange
1309
+ except ModuleNotFoundError :
1310
+ raise NotImplementedError (
1311
+ "The dataframe you provided supports the dataframe interchange"
1312
+ "protocol, "
1313
+ "but pandas 1.5.0 or greater is required to consume it."
1314
+ )
1315
+ df_not_pandas = args ["data_frame" ]
1316
+ df_pandas = pandas .api .interchange .from_dataframe (df_not_pandas )
1317
+ args ["data_frame" ] = df_pandas
1315
1318
else :
1316
1319
args ["data_frame" ] = pd .DataFrame (args ["data_frame" ])
1317
1320
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