Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
0586fd72
Commit
0586fd72
authored
Dec 24, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add app list
parent
379debf6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
applist.py
tensnsorflow/applist.py
+9
-4
No files found.
tensnsorflow/applist.py
View file @
0586fd72
import
pandas
as
pd
import
pandas
as
pd
import
pymysql
import
pymysql
import
json
def
con_sql
(
db
,
sql
):
def
con_sql
(
db
,
sql
):
cursor
=
db
.
cursor
()
cursor
=
db
.
cursor
()
...
@@ -14,16 +15,20 @@ def con_sql(db,sql):
...
@@ -14,16 +15,20 @@ def con_sql(db,sql):
db
.
close
()
db
.
close
()
return
df
return
df
def
json_format
(
x
):
a
=
json
.
loads
(
x
)
return
set
([
x
[
"appName"
]
for
x
in
a
])
def
sort_app
():
def
sort_app
():
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_prod'
)
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_prod'
)
sql
=
"select device_id,app_list from device_id_applist limit 6"
sql
=
"select device_id,app_list from device_id_applist limit 6"
df
=
con_sql
(
db
,
sql
)
df
=
con_sql
(
db
,
sql
)
a
=
df
[
1
]
.
values
.
tolist
()
a
=
df
[
1
]
.
values
.
tolist
()
print
(
type
(
a
[
0
]))
print
(
type
(
a
[
0
]))
# df[1]=df[1].apply(lambda x:set([i["appName"] for i in x])
)
df
[
1
]
=
df
[
1
]
.
apply
(
json_format
)
#
dianshang = {"美团","京东","淘宝"}
dianshang
=
{
"美团"
,
"京东"
,
"淘宝"
}
#
df[2] = df[1].apply(lambda x:1 if len(x&dianshang)>0 else 0)
df
[
2
]
=
df
[
1
]
.
apply
(
lambda
x
:
1
if
len
(
x
&
dianshang
)
>
0
else
0
)
#
print(df[2].unique())
print
(
df
[
2
]
.
unique
())
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
sort_app
()
sort_app
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment