Skip to content

Commit 57ba250

Browse files
committed
Merge pull request #861 from plotly/fix-pandas-orient-arg
Fix pandas orient arg (to_dict("rows") -> to_dict("records"))
1 parent e2e0b4d commit 57ba250

12 files changed

+24
-42
lines changed

packages/dash-table/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ app = dash.Dash(__name__)
2222
app.layout = dash_table.DataTable(
2323
id='table',
2424
columns=[{"name": i, "id": i} for i in df.columns],
25-
data=df.to_dict("rows"),
25+
data=df.to_dict('records'),
2626
)
2727

2828
if __name__ == '__main__':

packages/dash-table/dash_table_base/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from __future__ import print_function as _
1+
from __future__ import print_function
22

33
import os as _os
44
import sys as _sys
55
import json
66

77
import dash as _dash
88

9-
if not hasattr(_dash, '__plotly_dash') and not hasattr(_dash, 'development'):
9+
if not hasattr(_dash, "__plotly_dash") and not hasattr(_dash, "development"):
1010
print(
1111
"Dash was not successfully imported. "
1212
"Make sure you don't have a file "

packages/dash-table/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
"private::build:backends": "dash-generate-components src/dash-table/dash/DataTable.js dash_table -p package-info.json && cp dash_table_base/** dash_table/ && dash-generate-components src/dash-table/dash/DataTable.js dash_table -p package-info.json --r-prefix 'dash' --r-suggests 'dash' --jl-prefix 'dash'",
2525
"private::format.ts": "npm run private::lint.ts -- --fix",
2626
"private::format.prettier": "prettier --config .prettierrc --write \"src/**/*.{js,ts,tsx}\"",
27-
"private::format.black": "black --exclude dash_table .",
27+
"private::format.black": "black dash_table_base tests",
2828
"private::host_js": "http-server ./dash_table -c-1 --silent",
2929
"private::lint.ts": "tslint --project tsconfig.json --config tslint.json",
30-
"private::lint.flake": "flake8 --exclude=dash_table,node_modules,venv",
31-
"private::lint.black": "black --check --exclude dash_table .",
30+
"private::lint.flake": "flake8 dash_table_base tests",
31+
"private::lint.black": "black --check dash_table_base tests",
3232
"private::lint.prettier": "prettier --config .prettierrc \"src/**/*.{js,ts,tsx}\" --list-different",
3333
"private::wait_js": "wait-on http://localhost:8080",
3434
"private::opentests": "cypress open",

packages/dash-table/tests/selenium/test_basic_copy_paste.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
url = "https://github.com/plotly/datasets/raw/master/" "26k-consumer-complaints.csv"
1515
rawDf = pd.read_csv(url)
16-
df = rawDf.to_dict("rows")
16+
df = rawDf.to_dict("records")
1717

1818

1919
def get_app():

packages/dash-table/tests/selenium/test_basic_operations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
url = "https://github.com/plotly/datasets/raw/master/" "26k-consumer-complaints.csv"
1212
rawDf = pd.read_csv(url)
13-
df = rawDf.to_dict("rows")
13+
df = rawDf.to_dict("records")
1414

1515

1616
def get_app():

packages/dash-table/tests/selenium/test_bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
url = "https://github.com/plotly/datasets/raw/master/" "26k-consumer-complaints.csv"
1111
rawDf = pd.read_csv(url)
12-
df = rawDf.to_dict("rows")
12+
df = rawDf.to_dict("records")
1313

1414

1515
def get_app(fixed_rows, fixed_columns, ops):

packages/dash-table/tests/selenium/test_derived_props.py

+7-16
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
rawDf = pd.read_csv(url, nrows=100)
1414
rawDf["id"] = rawDf.index + 3000
1515

16-
df = rawDf.to_dict("rows")
16+
df = rawDf.to_dict("records")
1717

1818
props = [
1919
"active_cell",
@@ -57,7 +57,7 @@ def get_app():
5757
)
5858

5959
@app.callback(
60-
Output("props_container", "children"), [Input("table", prop) for prop in props],
60+
Output("props_container", "children"), [Input("table", prop) for prop in props]
6161
)
6262
def show_props(*args):
6363
# return 'Something yet!'
@@ -68,7 +68,7 @@ def show_props(*args):
6868
[
6969
html.Td(prop),
7070
html.Td(
71-
json.dumps(val) if val is not None else "None", id=prop,
71+
json.dumps(val) if val is not None else "None", id=prop
7272
),
7373
]
7474
)
@@ -212,10 +212,7 @@ def test_tdrp003_select_cells(test):
212212
for col in range(3):
213213
selected.append(
214214
dict(
215-
row=row,
216-
column=col,
217-
column_id=rawDf.columns[col],
218-
row_id=row + 3000,
215+
row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000
219216
)
220217
)
221218

@@ -275,10 +272,7 @@ def test_tdrp003_select_cells(test):
275272
for col in range(2):
276273
selected.append(
277274
dict(
278-
row=row,
279-
column=col,
280-
column_id=rawDf.columns[col],
281-
row_id=row + 3000,
275+
row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000
282276
)
283277
)
284278

@@ -345,17 +339,14 @@ def test_tdrp004_navigate_selected_cells(test):
345339
for col in range(3):
346340
selected.append(
347341
dict(
348-
row=row,
349-
column=col,
350-
column_id=rawDf.columns[col],
351-
row_id=row + 3000,
342+
row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000
352343
)
353344
)
354345

355346
for row in range(3):
356347
for col in range(3):
357348
active = dict(
358-
row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000,
349+
row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000
359350
)
360351

361352
assert test.find_element("#active_cell").get_attribute(

packages/dash-table/tests/selenium/test_editable.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
url = "https://github.com/plotly/datasets/raw/master/" "26k-consumer-complaints.csv"
1515
rawDf = pd.read_csv(url)
16-
df = rawDf.to_dict("rows")
16+
df = rawDf.to_dict("records")
1717

1818

1919
def get_app_and_locks():
@@ -44,7 +44,7 @@ def get_app_and_locks():
4444
non_blocking_lock = Lock()
4545

4646
@app.callback(
47-
Output("table", "style_cell_conditional"), [Input("non-blocking", "n_clicks")],
47+
Output("table", "style_cell_conditional"), [Input("non-blocking", "n_clicks")]
4848
)
4949
def non_blocking_callback(clicks):
5050
if clicks is None:

packages/dash-table/tests/selenium/test_markdown_copy_paste.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
rawDf["Issue"] = rawDf["Issue"].map(lambda x: "![" + str(x) + "](assets/logo.png)")
1212
rawDf["State"] = rawDf["State"].map(lambda x: '```python\n"{}"\n```'.format(x))
1313

14-
df = rawDf.to_dict("rows")
14+
df = rawDf.to_dict("records")
1515

1616

1717
def get_app():

packages/dash-table/tests/selenium/test_markdown_link.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
def get_app(cell_selectable, markdown_options):
77
md = "[Click me](https://www.google.com)"
88

9-
data = [
10-
dict(a=md, b=md),
11-
dict(a=md, b=md),
12-
]
9+
data = [dict(a=md, b=md), dict(a=md, b=md)]
1310

1411
app = dash.Dash(__name__)
1512

packages/dash-table/tests/selenium/test_pagination.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
url = "https://github.com/plotly/datasets/raw/master/" "26k-consumer-complaints.csv"
1414
rawDf = pd.read_csv(url)
15-
df = rawDf.to_dict("rows")
15+
df = rawDf.to_dict("records")
1616

1717
PAGE_SIZE = 5
1818
pages = math.ceil(len(df) / PAGE_SIZE)

packages/dash-table/tests/selenium/test_scrolling.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,11 @@ def test_scrol001_fixed_alignment(test, fixed_rows, fixed_columns, ops):
7575

7676
scroll_by(test, 200)
7777

78-
wait.until(
79-
lambda: -get_margin(test) == fixed_width + 200, 3,
80-
)
78+
wait.until(lambda: -get_margin(test) == fixed_width + 200, 3)
8179

8280
scroll_by(test, -200)
8381

84-
wait.until(
85-
lambda: -get_margin(test) == fixed_width, 3,
86-
)
82+
wait.until(lambda: -get_margin(test) == fixed_width, 3)
8783
assert test.get_log_errors() == []
8884

8985

@@ -131,7 +127,5 @@ def test_scrol002_edit_navigate(test, fixed_rows, fixed_columns, ops):
131127
test.send_keys(Keys.ARROW_RIGHT)
132128

133129
wait.until(lambda: target.cell(2, 4).is_selected(), 3)
134-
wait.until(
135-
lambda: -get_margin(test) == fixed_width + get_scroll(test), 3,
136-
)
130+
wait.until(lambda: -get_margin(test) == fixed_width + get_scroll(test), 3)
137131
assert test.get_log_errors() == []

0 commit comments

Comments
 (0)