-
Notifications
You must be signed in to change notification settings - Fork 294
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
Fix display of non-numeric DataFrame index columns #5254
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5254 +/- ##
=====================================
Coverage 73% 73%
=====================================
Files 401 401
Lines 26522 26532 +10
Branches 3869 3872 +3
=====================================
+ Hits 19441 19453 +12
+ Misses 5476 5474 -2
Partials 1605 1605
|
@@ -170,6 +170,17 @@ def _VSCODE_getDataFrameInfo(df): | |||
|
|||
columnTypes = _VSCODE_builtins.list(df.dtypes) | |||
|
|||
# Compute the index column. It may have been renamed | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit different from the code in getJupyterVariableDataFrameInfo.py that does something similar with index column. Looks like your version might be safer with the try / except. Should that maybe be updated as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually just restoring code that I removed several PRs ago. Rich pointed out at the time that he thought it was required, and now I see why 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, maybe I didn't say that right. I was saying that this code here looked safer than the code in the other location. Just wondering if getJupyterVariableDataFrameInfo.py should be upgraded with the try / except that you have here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good point, will update
For #5253
The change here is to show the index column in addition to the row number column only for pandas DataFrames and Series objects, because index columns are meaningful for DFs and Series but for ndarrays, lists, dicts and tensors the index column is generated by us as part of the DataFrame conversion code and is hence not meaningful to the user.
DataFrame:
Same data as an ndarray (note that there isn't actually an index column being generated on the ndarray itself):
package-lock.json
has been regenerated by runningnpm install
(if dependencies have changed).