Plotly Express constructor: in wide mode, lists passed to `x` and `y` params are mutated
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 18.8k
- Forks
- 2.8k
- Merge medio
- 16 h 26 min
- PR fusionados (30 d)
- 21
Descripción
When either the x or y parameters to the Plotly Express constructor are passed lists of values, they are mutated such that values are converted to string.
Expected behaviour: Plotly Express should not mutate objects supplied as arguments by the user.
Minimal example (tested on Plotly 5.13.1 and master branch):
from random import randrange
import pandas as pd
import plotly.express as px
cols, rows = list(range(3)), list(range(10))
print(cols)
df = pd.DataFrame({col: [randrange(100) for _row in rows] for col in cols})
px.bar(df, y=cols, barmode="group")
print(cols)
Before the px.bar() call, cols has the value [1, 2, 3] and afterwards it is ["1", "2", "3"]. The same behaviour occurs for the x param and also when using other plotting functions than pxbar() (I tried px.histogram()).
I did some poking around, and can see that in the function build_dataframe in plotly/express/_core.py, the some of the fields in the user supplied args have copies made (which would fix this issue), but that is only applied to args found in the array_attrables list, which is ["dimensions", "custom_data", "hover_data", "path", "wide_variable"], which does not include x and y.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza en plotly/express/_core.py y lee build_dataframe, especialmente cómo array_attrables controla la copia de los argumentos proporcionados por el usuario. Reproduce el ejemplo mínimo con listas de x o y en modo wide y verifica después que las listas originales conservan sus valores y no se convierten en cadenas tras la llamada al constructor.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- pandas, python
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 35/100