Skip to content

Commit 671ea4d

Browse files
committed
api.py: applymap removal
1 parent 63a1216 commit 671ea4d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export APP_VERSION = ${tag}-${version}
108108
commit = ${APP_VERSION}
109109
lastcommit := $(shell touch .lastcommit && cat .lastcommit)
110110
date := $(shell date -I)
111-
id := $(shell openssl rand -base64 8)
111+
id:=myid
112112

113113
vm_max_count := $(shell cat /etc/sysctl.conf | egrep vm.max_map_count\s*=\s*262144 && echo true)
114114

code/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def post(self, dataset):
610610
except:
611611
return {"data": [{"error": "error: no such table {}".format(ds.table)}]}
612612
df = df.head(n=size).reset_index(drop=True)
613-
df = df.applymap(lambda x: unicode_safe(x))
613+
df = df.apply(lambda col: col.map(unicode_safe))
614614
if (format_type == 'json'):
615615
return {"data": list(df.fillna("").T.to_dict().values()), "schema": schema}
616616
elif (format_type == 'csv'):
@@ -957,7 +957,7 @@ def post(self, recipe, action):
957957
try:
958958
return jsonify({"data": list(df.T.to_dict().values()), "log": str(r.log.writer.getvalue())})
959959
except:
960-
df = df.applymap(lambda x: str(x))
960+
df = df.apply(lambda col: col.astype(str))
961961
return jsonify({"data": list(df.T.to_dict().values()), "log": str(r.log.writer.getvalue())})
962962
else:
963963
return {"log": r.log.writer.getvalue()}
@@ -993,7 +993,7 @@ def put(self, recipe, action):
993993
try:
994994
return jsonify({"data": list(df.T.to_dict().values()), "log": r.callback["log"]})
995995
except:
996-
df = df.applymap(lambda x: unicode_safe(x))
996+
df = df.apply(lambda col: col.map(unicode_safe))
997997
return jsonify({"data": list(df.T.to_dict().values()), "log": r.callback["log"]})
998998
else:
999999
return {"data": [{"result": "empty"}], "log": r.callback["log"]}

0 commit comments

Comments
 (0)