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

pandas version 140: "Error displaying widget" for dataframe with null data #5

Open
GaryScottMartin opened this issue Feb 2, 2022 · 1 comment

Comments

@GaryScottMartin
Copy link

GaryScottMartin commented Feb 2, 2022

Upgrade to pandas 1.4.0 resulted in "Error displaying widget" for pandas dateframe containing dummy data, but not for dataframe containing valid data. Both sets of code below worked properly prior to upgrade to 1.4.0. Problem resolved by going back to pandas 1.3.5. Pandas 1.4.0 works properly for me with a pandas dataframe with valid data, but not with dummy data (valid dates but null numeric and datetime values meant to be replaced from qgrid.

This code still works in pandas 1.4.0
`
#Import libraries
import pandas as pd
pd.options.plotting.backend = "matplotlib"
import datetime as dt
import numpy as np
import qgrid as qg
%load_ext sql

%sql sqlite:///NightlySleepDurations.sqlite3
result = %sql SELECT * from SLEEP_DURATIONS;
df = result.DataFrame()
df["sleep_date"] = pd.to_datetime(df["sleep_date"])
df_qg = qg.show_grid(df, show_toolbar = True)`

df_qg

This code produces "Error displaying widget:"

'
#Import libraries
import pandas as pd
pd.options.plotting.backend = "matplotlib"
import datetime as dt
import numpy as np
import qgrid as qg
%load_ext sql

def td_to_str(x):
ts = x.total_seconds()
hours, remainder = divmod(ts, 3600)
minutes, seconds = divmod(remainder, 60)
return ('{:02d}:{:02d}').format(int(hours), int(minutes))

def td_to_hrs(x):
return x.total_seconds()/3600

adtnl_rows = None
%sql sqlite:///NightlySleepDurations.sqlite3
result = %sql SELECT * from SLEEP_DURATIONS;
df = result.DataFrame()
len_in = df.shape[0]
df["sleep_date"] = pd.to_datetime(df["sleep_date"])
last_date_in = df.loc[len_in-1,"sleep_date"]
days_to_add = (dt.datetime.now() - last_date_in).days
if days_to_add > 0:
day_to_add_first = last_date_in + dt.timedelta(days=1)
day_to_add_last = last_date_in + dt.timedelta(days=days_to_add)
dummy_index = np.arange(1,days_to_add+1,1)
dti = pd.date_range(start = day_to_add_first, end = day_to_add_last, freq='D')
dummy_td = pd.Series(np.nan,index=dummy_index,dtype='float64')
dummy_tdhm = pd.Series(np.nan,index=dummy_index,dtype='string')
adtnl_rows = pd.DataFrame({ 'sleep_date': dti,
'total_duration': dummy_td,
'total_duration_hm': dummy_tdhm
})
df_qg=qg.show_grid(adtnl_rows, show_toolbar=True)
'

'df_qg'
"Error displaying widget:"

================================
While repeating the install process the following are warnings produced by npm in the setyup.py step. (Not sure this is significant, but I don't remember seeing these warnings previously.)

`Installing build dependencies with npm. This may take a while...
npm WARN deprecated [email protected]: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see request/request#3142
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated [email protected]: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1

`

@GaryScottMartin GaryScottMartin changed the title JupyterLab 3.2.8: Error displaying widget JupyterLab 3.2.8: Error displaying widget (may be related to pandas upgrade) Feb 4, 2022
@GaryScottMartin GaryScottMartin changed the title JupyterLab 3.2.8: Error displaying widget (may be related to pandas upgrade) pandas version 140: "Error displaying widget" for dataframe with null data Feb 4, 2022
@JohnOmernik
Copy link
Collaborator

Highly recommend people check out https://github.com/zhihanyue/qgridnext

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