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: unhashable type: 'list' #96
Comments
I also get this error now.
|
This was due to a new feature using df.unique() on DataFrames containing unhashable data like lists, I've replaced it with an alternative that works with unhashable data by converting to strings. Can you try out the dev branch and let me know if it's fixed for you?
This isn't an error, it's a warning that PandasGUI automatically converts DataFrame column names to strings. You just got a really long warning message because it seems like your data has over 10k columns all with numeric column values. For example
|
I did pip install git+https://github.com/adamerose/pandasgui.git TypeError Traceback (most recent call last) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\gui.py in show(settings, *args, **kwargs) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\gui.py in init(self, settings, **kwargs) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\store.py in add_dataframe(self, pgdf, name) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in clean_dataframe(df, name) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in parse_dates(df) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\frame.py in apply(self, func, axis, raw, result_type, args, **kwds) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in get_result(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in apply_standard(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in apply_series_generator(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in (col) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in _maybe_cache(arg, format, cache, convert_listlike) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in should_cache(arg, unique_share, check_count) TypeError: unhashable type: 'list' |
Can you share a sample dataset that causes this error? |
`import pandas as pd client = ArangoClient(hosts='http://bjhjemme.duckdns.org:8529') db = client.db('test_2015-2020', username='test', password='test') aql = db.aql cursor = db.aql.execute('FOR c IN FORM_3 RETURN c', batch_size=1) df = pd.json_normalize(result, max_level=None) df = df.drop(columns=['_key', '_id', '_rev']) |
Looks like this is a problem with Pandas, I made an issue here pandas-dev/pandas#39756 But in the meantime I've added a workaround to PandasGUI, can you try again after |
Hi, yours patch dont work. when I downgrade pandas to 1.0.5 I get this pip install pandas==1.0.5 TypeError Traceback (most recent call last) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\gui.py in show(settings, *args, **kwargs) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\gui.py in init(self, settings, **kwargs) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\store.py in add_dataframe(self, pgdf, name) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in clean_dataframe(df, name) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in parse_dates(df) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\frame.py in apply(self, func, axis, raw, result_type, args, **kwds) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in get_result(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in apply_standard(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in apply_series_generator(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in (col) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in _maybe_cache(arg, format, cache, convert_listlike) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in should_cache(arg, unique_share, check_count) TypeError: unhashable type: 'list' Then I upgrade everything and pip install --upgrade git+https://github.com/adamerose/pandasgui.git I get this TypeError Traceback (most recent call last) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\gui.py in show(settings, *args, **kwargs) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\gui.py in init(self, settings, **kwargs) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\store.py in add_dataframe(self, pgdf, name) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in clean_dataframe(df, name) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in parse_dates(df) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\frame.py in apply(self, func, axis, raw, result_type, args, **kwds) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in get_result(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in apply_standard(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\apply.py in apply_series_generator(self) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandasgui\utility.py in (col) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in _maybe_cache(arg, format, cache, convert_listlike) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\tools\datetimes.py in should_cache(arg, unique_share, check_count) TypeError: unhashable type: 'list' But when I downgrade pandasgui to pip install pandasgui==0.2.7 |
I don't think you were on the latest version, because your stack trace still shows
which was removed from the code. I released the fix to PyPi, please try 0.2.9 |
Ok, 0.2.9 works now PandasGUI WARNING — pandasgui.utility — In df, converted columns to datetime: DOFFIN_ESENDERS.DOFFIN_APPENDIX.DOFFIN_FORM_TYPE.NATIONAL.REFERENCE_SECTION.REFERENCE_DOFFIN.DATE <pandasgui.gui.PandasGui at 0x1b12641cd30> but pandasgui show :) |
Hi again I am trying this on mulitindexing https://github.com/ZaxR/pandas_multiindex_tutorial/blob/master/Pandas%20MultiIndex%20Tutorial.ipynb In [29]: multi_col_lvl_df.query("Date == '2018-07-10' and Category == 'Wine'") that works in atom and hydrogen pluging. but if I do show(multi_col_lvl_df) <pandasgui.gui.PandasGui at 0x1b3eea8f790> During handling of the above exception, another exception occurred: Traceback (most recent call last): The above exception was the direct cause of the following exception: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): The above exception was the direct cause of the following exception: Traceback (most recent call last): But if I type Date == '2018-07-10' and Category == 'Wine' Is it a bug or? |
@bjornjorgensen Can you give a minimal example with a URL link to the CSV? |
I have a related issue where non-dates are often converted to datetime. I changed utility.py line 242 to
It does convert everything else to a string (like float columns), but that is not a big issue for me, visually. |
The date conversion seems to work fine on my end, it detected dates in RecordingDate, RecordingStartTime and RecordingStopTime. Can you try again with the latest version PandasGUI just tries calling # Automatically try to parse dates for all columns
def parse_dates(df: Union[pd.DataFrame, pd.Series]):
def parse_dates_series(s: pd.Series):
try:
return pd.to_datetime(s)
except:
return s
if type(df) == pd.DataFrame:
return df.apply(lambda col: parse_dates_series(col) if col.dtype == object else col)
elif type(df) == pd.Series:
return parse_dates_series(df)
That shouldn't happen either and doesn't happen for me on your txt file, I only get 7 string columns. |
At this point your bug doesn't seem to be related to this issue, can you make a new issue for us to continue this discussion? A pickle would be good, but I think the easiest way to debug would be to try calling my cleaning function directly so we can rule out any graphic bugs. For example from pandasgui.utility import clean_dataframe
from pandasgui.datasets import trump_tweets
df = clean_dataframe(trump_tweets) Once you make a new issue I will try to replicate your bug with your version of
The goal of this project is to make viewing and analyzing data in Pandas as quick and intuitive as possible, and I found having to specify a list of column names in my dataset that are dates very tedious. Other EDA and viz programs like JMP, Tableau and PowerBI all recognize columns containing strings that represent dates and that's what I wanted for PandasGUI too. Aside from automatically parsing dates, it also removes non-string and duplicate column names, this all happens in
Yep that's expected, I pulled my CSS into a separate package for easier maintenance. |
Hi just upgraded to 0.2.8 now and then I starting to get this error
Environment
OS: (eg. Windows 10)
Python: (eg. 3.9)
The text was updated successfully, but these errors were encountered: