Skip to content

Fixed index retrival for dts w/ multiindex #46

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

Merged
merged 1 commit into from
Sep 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/inspectorscripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def _jupyterlab_variableinspector_getcontentof(x):
# pandas and numpy
if pd and isinstance(x, pd.DataFrame):
colnames = ', '.join(x.columns.map(str))
content = "Column names: %s" % colnames
content = "Column names: %s" % colnames
elif pd and isinstance(x, pd.Series):
content = "Series [%d rows]" % x.shape
content = "Series [%d rows]" % x.shape
elif np and isinstance(x, np.ndarray):
content = x.__repr__()
else:
Expand Down Expand Up @@ -150,15 +150,13 @@ def _jupyterlab_variableinspector_getmatrixcontent(x, max_rows=10000):
if threshold is not None:
x = x.head(threshold)
x.columns = x.columns.map(str)
response = {"schema": pd.io.json.build_table_schema(x), "data": x.to_dict(orient="records")}
return json.dumps(response, default=_jupyterlab_variableinspector_default)
return x.to_json(orient="table", default_handler=_jupyterlab_variableinspector_default)
elif np and pd and type(x).__name__ in ["ndarray"]:
df = pd.DataFrame(x)
if threshold is not None:
df = df.head(threshold)
df.columns = df.columns.map(str)
response = {"schema": pd.io.json.build_table_schema(df), "data": df.to_dict(orient="records")}
return json.dumps(response,default=_jupyterlab_variableinspector_default)
return df.to_json(orient="table", default_handler=_jupyterlab_variableinspector_default)
elif tf and (isinstance(x, tf.Variable) or isinstance(x, tf.Tensor)):
df = K.get_value(x)
return _jupyterlab_variableinspector_getmatrixcontent(df)
Expand Down