Skip to content

Commit d84b3de

Browse files
authored
Merge pull request #5418 from Microsoft/rchiodo/release_update_2
Fix sorting of number only lists (#5416)
2 parents eec6aaa + 73a4d6f commit d84b3de

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

news/2 Fixes/5414.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix sorting of lists with numbers and missing entries.

pythonFiles/datascience/getJupyterVariableDataFrameInfo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
_VSCODE_columnTypes = []
2424
_VSCODE_columnNames = []
2525
if _VSCODE_targetVariable['type'] == 'list':
26-
_VSCODE_columnTypes = ['string'] # Might be able to be more specific here?
27-
_VSCODE_columnNames = ['_VSCode_JupyterValuesColumn']
26+
_VSCODE_evalResult = _VSCODE_pd.DataFrame(_VSCODE_evalResult)
27+
_VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes)
28+
_VSCODE_columnNames = list(_VSCODE_evalResult)
2829
elif _VSCODE_targetVariable['type'] == 'Series':
2930
_VSCODE_evalResult = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)
3031
_VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes)

pythonFiles/datascience/getJupyterVariableDataFrameRows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Assume we have a dataframe. If not, turn our eval result into a dataframe
1717
_VSCODE_df = _VSCODE_evalResult
1818
if (_VSCODE_targetVariable['type'] == 'list'):
19-
_VSCODE_df = _VSCODE_pd.DataFrame({'_VSCode_JupyterValuesColumn':_VSCODE_evalResult})
19+
_VSCODE_df = _VSCODE_pd.DataFrame(_VSCODE_evalResult)
2020
elif (_VSCODE_targetVariable['type'] == 'Series'):
2121
_VSCODE_df = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)
2222
elif _VSCODE_targetVariable['type'] == 'dict':

src/datascience-ui/data-explorer/mainPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
366366
// or it will take too long
367367
const comparer = isStringColumn ?
368368
(a: any, b: any): number => {
369-
const aVal = a[sortColumn] as string;
370-
const bVal = b[sortColumn] as string;
369+
const aVal = a[sortColumn] ? a[sortColumn].toString() : '';
370+
const bVal = b[sortColumn] ? b[sortColumn].toString() : '';
371371
const aStr = aVal ? aVal.substring(0, Math.min(aVal.length, MaxStringCompare)) : aVal;
372372
const bStr = bVal ? bVal.substring(0, Math.min(bVal.length, MaxStringCompare)) : bVal;
373373
const result = aStr > bStr ? -1 : 1;

0 commit comments

Comments
 (0)