Skip to content

Commit

Permalink
Merge pull request #5418 from Microsoft/rchiodo/release_update_2
Browse files Browse the repository at this point in the history
Fix sorting of number only lists (#5416)
  • Loading branch information
rchiodo committed Apr 23, 2019
2 parents eec6aaa + 73a4d6f commit d84b3de
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/5414.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix sorting of lists with numbers and missing entries.
5 changes: 3 additions & 2 deletions pythonFiles/datascience/getJupyterVariableDataFrameInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
_VSCODE_columnTypes = []
_VSCODE_columnNames = []
if _VSCODE_targetVariable['type'] == 'list':
_VSCODE_columnTypes = ['string'] # Might be able to be more specific here?
_VSCODE_columnNames = ['_VSCode_JupyterValuesColumn']
_VSCODE_evalResult = _VSCODE_pd.DataFrame(_VSCODE_evalResult)
_VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes)
_VSCODE_columnNames = list(_VSCODE_evalResult)
elif _VSCODE_targetVariable['type'] == 'Series':
_VSCODE_evalResult = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)
_VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes)
Expand Down
2 changes: 1 addition & 1 deletion pythonFiles/datascience/getJupyterVariableDataFrameRows.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Assume we have a dataframe. If not, turn our eval result into a dataframe
_VSCODE_df = _VSCODE_evalResult
if (_VSCODE_targetVariable['type'] == 'list'):
_VSCODE_df = _VSCODE_pd.DataFrame({'_VSCode_JupyterValuesColumn':_VSCODE_evalResult})
_VSCODE_df = _VSCODE_pd.DataFrame(_VSCODE_evalResult)
elif (_VSCODE_targetVariable['type'] == 'Series'):
_VSCODE_df = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)
elif _VSCODE_targetVariable['type'] == 'dict':
Expand Down
4 changes: 2 additions & 2 deletions src/datascience-ui/data-explorer/mainPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
// or it will take too long
const comparer = isStringColumn ?
(a: any, b: any): number => {
const aVal = a[sortColumn] as string;
const bVal = b[sortColumn] as string;
const aVal = a[sortColumn] ? a[sortColumn].toString() : '';
const bVal = b[sortColumn] ? b[sortColumn].toString() : '';
const aStr = aVal ? aVal.substring(0, Math.min(aVal.length, MaxStringCompare)) : aVal;
const bStr = bVal ? bVal.substring(0, Math.min(bVal.length, MaxStringCompare)) : bVal;
const result = aStr > bStr ? -1 : 1;
Expand Down

0 comments on commit d84b3de

Please sign in to comment.