lets-plot icon indicating copy to clipboard operation
lets-plot copied to clipboard

Int DataFrame column names are being converted to float string representation

Open kuroski opened this issue 2 years ago • 2 comments

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.

image

kuroski avatar Oct 11 '23 08:10 kuroski

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

image

Lets_plot Example

image

Zaf4 avatar Nov 04 '23 14:11 Zaf4

Related: #626

alshan avatar Nov 07 '23 19:11 alshan