forked from graph-knowledgegraph/KDD2019-HandsOn-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.GraphStatsDemo.py
88 lines (66 loc) · 3.26 KB
/
1.GraphStatsDemo.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Databricks notebook source
# MAGIC %md # Module I. Graph Stats
# COMMAND ----------
# MAGIC %run "./TutorialClasses"
# COMMAND ----------
# MAGIC %md ## Get Dataframes
# COMMAND ----------
# Azure Storage account name
MagAccount = 'kdd2019magstore'
# MAG container name
MagContainer = 'mag-2019-06-07'
# Shared access signature of MAG Container
MagSAS = '?sv=2018-03-28&ss=bfqt&srt=sco&sp=rl&se=2019-08-10T02:22:11Z&st=2019-07-31T18:22:11Z&spr=https&sig=m8XIxbDhk3ZOBt5ceVYIodw3k0JhbXodUBZDxXOThcs%3D'
# COMMAND ----------
mag = MicrosoftAcademicGraph(container=MagContainer, account=MagAccount, sas=MagSAS)
# COMMAND ----------
Affiliations = mag.getDataframe('Affiliations')
display(Affiliations)
# COMMAND ----------
Authors = mag.getDataframe('Authors')
ConferenceInstances = mag.getDataframe('ConferenceInstances')
ConferenceSeries = mag.getDataframe('ConferenceSeries')
EntityRelatedEntities = mag.getDataframe('EntityRelatedEntities')
FieldsOfStudy = mag.getDataframe('FieldsOfStudy')
FieldOfStudyChildren = mag.getDataframe('FieldOfStudyChildren')
Journals = mag.getDataframe('Journals')
Papers = mag.getDataframe('Papers')
PaperAbstractsInvertedIndex = mag.getDataframe('PaperAbstractsInvertedIndex')
PaperAuthorAffiliations = mag.getDataframe('PaperAuthorAffiliations')
PaperCitationContexts = mag.getDataframe('PaperCitationContexts')
PaperFieldsOfStudy = mag.getDataframe('PaperFieldsOfStudy')
PaperReferences = mag.getDataframe('PaperReferences')
PaperUrls = mag.getDataframe('PaperUrls')
PaperRecommendations = mag.getDataframe('PaperRecommendations')
PaperResources = mag.getDataframe('PaperResources')
RelatedFieldOfStudy = mag.getDataframe('RelatedFieldOfStudy')
# COMMAND ----------
# MAGIC %md ## Entity Counts
# COMMAND ----------
formatStr = '{:<16} | {:>8}'
print(formatStr.format('Table', 'Count'))
print('-----------------+---------')
print(formatStr.format('Papers', Papers.count()))
print(formatStr.format('Authors', Authors.count()))
print(formatStr.format('FieldsOfStudy', FieldsOfStudy.count()))
print(formatStr.format('ConferenceSeries', ConferenceSeries.count()))
print(formatStr.format('Journals', Journals.count()))
print(formatStr.format('Affiliations', Affiliations.count()))
# COMMAND ----------
# MAGIC %md ## Other Dataframe Counts
# COMMAND ----------
formatStr = '{:<27} | {:>8}'
print(formatStr.format('Table', 'Count'))
print('----------------------------+---------')
print(formatStr.format('ConferenceInstances', ConferenceInstances.count()))
print(formatStr.format('EntityRelatedEntities', EntityRelatedEntities.count()))
print(formatStr.format('FieldOfStudyChildren', FieldOfStudyChildren.count()))
print(formatStr.format('PaperAbstractsInvertedIndex', PaperAbstractsInvertedIndex.count()))
print(formatStr.format('PaperAuthorAffiliations', PaperAuthorAffiliations.count()))
print(formatStr.format('PaperCitationContexts', PaperCitationContexts.count()))
print(formatStr.format('PaperFieldsOfStudy', PaperFieldsOfStudy.count()))
print(formatStr.format('PaperReferences', PaperReferences.count()))
print(formatStr.format('PaperUrls', PaperUrls.count()))
print(formatStr.format('PaperRecommendations', PaperRecommendations.count()))
print(formatStr.format('PaperResources', PaperResources.count()))
print(formatStr.format('RelatedFieldOfStudy', RelatedFieldOfStudy.count()))