lets-plot
lets-plot copied to clipboard
Int DataFrame column names are being converted to float string representation
Hello, I was working with the following scenario in a notebook.
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(100, 2))
In this example, I have two int columns 0 and 1.
When trying to plot the DataFrame
from lets_plot import *
ggplot(df) + geom_point(aes(x="0", y="1"))
I am presented with the following error message:
Variable not found: '0'. Variables in data frame: ['0.0', '1.0']
It seems for some reason, the names are being converted to a float string representation.
I checked and it's not a problem with lets_plot. It's a pandas problem. I used the same array and pandas dataframe got errors both in lets_plot and seaborn. But, when you convert the same dataframe to polars dataframe, both seaborn and lets_plot works.
df_pd = pd.DataFrame(np.random.rand(100, 2))
df_pl = pl.from_pandas(df_pd)
Seaborn Example
Lets_plot Example
Related: #626