TypeError: data type "category" not understood
See original GitHub issueHi, Trying to reproduce example. It is throwing following error for this code
# Main dataset to show datasloth capabilities
titanic = sns.load_dataset('titanic')
titanic.head()
titanic.sloth.description = 'Verbose description of the table'
sloth.query("Number of men which survived the titanic", show_query=True)
Output exceeds the [size limit](command:workbench.action.openSettings?[). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?5c05cb7d-1b4d-48ee-8e94-e8afceb177c6)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-12-b1e190aa764c> in <module>
5 titanic.head()
6 titanic.sloth.description = 'Verbose description of the table'
----> 7 sloth.query("Number of men which survived the titanic", show_query=True)
~/.local/lib/python3.6/site-packages/datasloth/__init__.py in query(self, query, env, show_query)
118 env = env or get_outer_frame_variables()
119 query = query[0].lower() + query[1:]
--> 120 prompt = self.dataframes_summary(env)
121 if not prompt:
122 print('No dataframes found')
~/.local/lib/python3.6/site-packages/datasloth/__init__.py in dataframes_summary(env, ignore)
102 summary_lines += [
103 f"\n\nTable name: {name}",
--> 104 value.sloth.description
105 ]
106 table_count += 1
~/.local/lib/python3.6/site-packages/datasloth/__init__.py in description(self)
27 @property
28 def description(self) -> str:
---> 29 return self._description.format(COLUMNS_SUMMARY=self.columns_summary())
...
--> 200 if is_string_dtype(col) or col.dtype == 'category':
201 unique = col.unique().tolist()
202 summary = 'unique values: ' + ', '.join(map(str, unique[:30]))
TypeError: data type "category" not understood
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
TypeError: data type 'category' not understood pandas ...
I have a dataframe df , with dtypes: category(16), float32(65), int32(41) . I want to perform some analysis on the categorical column. but...
Read more >Keep getting "data type 'category' not understood"? - Reddit
Hi, So I'm trying to convert my categorical data into numbers and use it for a correlation matrix. However, when I run this:...
Read more >Categorical Data — pandas 0.17.0 documentation - PyData |
Categoricals are a pandas data type, which correspond to categorical variables in ... TypeError: data type "category" not understood In [172]: dtype =...
Read more >astype errors with Categorical #16697 - pandas-dev ... - GitHub
dtypes[colname] == 'category' evaluates as True for categorical columns and raises TypeError: data type "category" not understood for np.float64 ...
Read more >5.12 Gotchas — Pandas Doc - GitHub Pages
TypeError : data type "category" not understood In [8]: dtype = pd. ... Series of type category should not work as Categoricals are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, great! Yes, it loads all dataframes in environment, apart from those which names start with an underscore. So if you want to “hide” something from it, you can name the variable that way (e.g.
_df
).Another way you can do it is to give datasloth a custom environment like this:
Sadly, it’s a bit ugly for now since I didn’t have much time to work on these custom envs. Make sure in that dict, the “keys” are the same as the variable names you use - you cannot pick a different name here. I have to do it like this since it’s impossible for datasloth to know what names you’ve used in your scope for this dataframes otherwise.
Very glad to hear you’re enjoying it! Just keep the questions coming if you find any other issue 😃