question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting TypeError while parsing a dataframe

See original GitHub issue

I’m facing TypeError while using pandas-profiling on a data as follows:

Summarize dataset: 2% 1/59 [00:09<09:20, 9.66s/it, Describe variable:project] -->>
.....
.......
~\Anaconda3\lib\site-packages\pandas\core\algorithms.py in isin(comps, values)
    441         # If the the values include nan we need to check for nan explicitly
    442         # since np.nan it not equal to np.nan
--> 443         if np.isnan(values).any():
    444             f = lambda c, v: np.logical_or(np.in1d(c, v), np.isnan(c))
    445         else:
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Please help. I have no idea what this is about.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
vperiyasamycommented, May 12, 2021

I checked out the pandas source and found the root cause: Here is where that 1 million threshold is coming from, and in the version of pandas I’m using (1.1.3) checks this with np.isnan instead of np.isna; as the OP mentioned above, np.isna is the more robust check. pandas==1.1.4+ includes this fix and resolves the issue for me.

1reaction
vperiyasamycommented, May 11, 2021

Here’s a snippet of what I’m using (Spark but converted to pandas):

from pandas_profiling import ProfileReport

spark_df = spark.range(10000000).selectExpr("id AS f1", "CONCAT('string id: ', id) AS f2", "'constant string' AS f3", "(id%3) == 0 AS f4", "(id+1) % 2 AS label")
df = spark_df.toPandas()
df_small = df[:1000001]

df_profile = ProfileReport(df_small, interactions={"continuous": False}, title="Profiling Report", progress_bar=False)
profile_html = df_profile.to_html()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting TypeError while parsing a dataframe into Pandas ...
Getting TypeError while parsing a dataframe into Pandas Profiling library ... I'm facing TypeError while using pandas-profiling on a data as ...
Read more >
Getting TypeError while parsing a dataframe #752 - GitHub
I'm facing TypeError while using pandas-profiling on a data as follows: Summarize dataset: 2% 1/59 [00:09<09:20, 9.66s/it, ...
Read more >
[Solved]-Getting TypeError while parsing a dataframe into Pandas ...
Coding example for the question Getting TypeError while parsing a dataframe into Pandas Profiling library-Pandas,Python.
Read more >
What's new in 2.0.0 (??) - Pandas
With the new behavior, we get exactly the requested dtype: ... As of version 2.0.0, parsing will use a consistent format, determined by...
Read more >
TypeError expected string or bytes-like object - STechies
This is usually encountered when a function that you are using or have defined is fed an integer or float. It might be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found