Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl committed Mar 24, 2021
1 parent 2bf99e3 commit 79b002b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
35 changes: 21 additions & 14 deletions src/datascience-ui/data-explorer/mainPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,20 +392,27 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
type: ColumnType.Number
};
const columns = [rowNumberColumn].concat(variable.columns);
return columns.reduce((accum: Slick.Column<Slick.SlickData>[], c: { key: string; type: ColumnType }, i: number) => {
// Only show index column for pandas DataFrame and Series
if ((variable?.type === 'DataFrame' || variable?.type === 'Series' || c.key !== this.state.indexColumn)) {
accum.push({
type: c.type,
field: c.key.toString(),
id: `${i}`,
name: c.key.toString(),
sortable: true,
formatter: cellFormatterFunc
} as Slick.Column<Slick.SlickData>);
}
return accum;
}, []);
return columns.reduce(
(accum: Slick.Column<Slick.SlickData>[], c: { key: string; type: ColumnType }, i: number) => {
// Only show index column for pandas DataFrame and Series
if (
variable?.type === 'DataFrame' ||
variable?.type === 'Series' ||
c.key !== this.state.indexColumn
) {
accum.push({
type: c.type,
field: c.key.toString(),
id: `${i}`,
name: c.key.toString(),
sortable: true,
formatter: cellFormatterFunc
} as Slick.Column<Slick.SlickData>);
}
return accum;
},
[]
);
}
return [];
}
Expand Down
6 changes: 4 additions & 2 deletions src/test/datascience/dataviewer.functional.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,15 @@ suite('DataScience DataViewer tests', () => {
});

runMountedTest('Transposed Data Frame', async (wrapper) => {
await injectCode('import pandas as pd\r\ndata = [["tom", 10], ["nick", 15], ["juli", 14]]\r\ndf = pd.DataFrame(data, columns=["Name", "Age"])\r\ndf = df.transpose()');
await injectCode(
'import pandas as pd\r\ndata = [["tom", 10], ["nick", 15], ["juli", 14]]\r\ndf = pd.DataFrame(data, columns=["Name", "Age"])\r\ndf = df.transpose()'
);
const gotAllRows = getCompletedPromise(wrapper);
const dv = await createJupyterVariableDataViewer('df', 'DataFrame');
assert.ok(dv, 'DataViewer not created');
await gotAllRows;

verifyRows(wrapper.wrapper, [0, "Name", "tom", "nick", "juli", 1, "Age", "10", "15", "14"]);
verifyRows(wrapper.wrapper, [0, 'Name', 'tom', 'nick', 'juli', 1, 'Age', '10', '15', '14']);
});

runMountedTest('List', async (wrapper) => {
Expand Down

0 comments on commit 79b002b

Please sign in to comment.