Skip to content

Commit bc8f920

Browse files
committed
Fix usage of 'column_names' that part of Interchange protocol
Signed-off-by: Anatoly Myachev <[email protected]>
1 parent 63b9ac5 commit bc8f920

File tree

1 file changed

+5
-1
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+5
-1
lines changed

Diff for: packages/python/plotly/plotly/express/_core.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,11 @@ def build_dataframe(args, constructor):
13271327

13281328
df_not_pandas = args["data_frame"]
13291329
args["data_frame"] = df_not_pandas.__dataframe__()
1330-
columns = args["data_frame"].column_names()
1330+
# According interchange protocol: `def column_names(self) -> Iterable[str]:`
1331+
# so this function can return for example a generator.
1332+
# The easiest way is to convert `columns` to `pandas.Index` so that the
1333+
# type is similar to the types in other code branches.
1334+
columns = pd.Index(args["data_frame"].column_names())
13311335
needs_interchanging = True
13321336
elif hasattr(args["data_frame"], "to_pandas"):
13331337
args["data_frame"] = args["data_frame"].to_pandas()

0 commit comments

Comments
 (0)