-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestqueryjson.py
More file actions
44 lines (36 loc) · 1.04 KB
/
testqueryjson.py
File metadata and controls
44 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pandas as pd
json = pd.read_json("News_Category_Dataset_v2.json", lines=True)
print(json.columns)
print(json.category.unique())
a = 0
b = 60
c = 0
d = b-a
dat = json[json.category == "FOOD & DRINK"].loc[:, ['headline', 'link']][a:b]
print("""-----------------
FOOD & DRINK
-----------------""")
for i in range(c, d):
print(dat.iloc[i, :].headline)
print(dat.iloc[i, :].link)
dat = json[json.category == "BUSINESS"].loc[:, ['headline', 'link']][a:b]
print("""-----------------
BUSINESS
-----------------""")
for i in range(c, d):
print(dat.iloc[i, :].headline)
print(dat.iloc[i, :].link)
dat = json[json.category == "EDUCATION"].loc[:, ['headline', 'link']][a:b]
print("""-----------------
EDUCATION
-----------------""")
for i in range(c, d):
print(dat.iloc[i, :].headline)
print(dat.iloc[i, :].link)
dat = json[json.category == "WORLD NEWS"].loc[:, ['headline', 'link']][a:b]
print("""-----------------
WORLD NEWS
-----------------""")
for i in range(c, d):
print(dat.iloc[i, :].headline)
print(dat.iloc[i, :].link)