Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"TypeError: data type not understood" with dtype: string #2036

Closed
Rik-de-Kort opened this issue Mar 23, 2020 · 1 comment
Closed

"TypeError: data type not understood" with dtype: string #2036

Rik-de-Kort opened this issue Mar 23, 2020 · 1 comment

Comments

@Rik-de-Kort
Copy link

Rik-de-Kort commented Mar 23, 2020

Pandas 1.0.2
Altair 4.0.1

Altair will raise an error on being given a DataFrame contain string dtypes. Casting the string columns to object will work fine. Related to #1931 but seems like it's an easier fix. Will try to develop a PR today if I can find the right pieces of code.

Minimal reproducer follows. Uncomment the fourth line to get the expected result.

import pandas as pd
import altair as alt
foo = pd.DataFrame({"a": ["foo", "bar", "baz"], "b": [4, 3, 2]})
foo["a"] = foo["a"].astype("string")
alt.Chart(foo).mark_bar().encode(x="a", y="b")

EDIT: It does work in 4.1.0dev0 since that already adds the checks for the dedicated string dtype in Pandas. Accordingly, I've resolved the problem by installing the dev version for now. Any hints on a release date?

@jakevdp
Copy link
Collaborator

jakevdp commented Mar 23, 2020

This was fixed by #1924, which will be part of the 4.1 release.

@jakevdp jakevdp closed this as completed Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants