Skip to content

Instantly share code, notes, and snippets.

@jwlin
Created September 5, 2017 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwlin/6f84cc1613b0c8c611da0735c9cd1f82 to your computer and use it in GitHub Desktop.
Save jwlin/6f84cc1613b0c8c611da0735c9cd1f82 to your computer and use it in GitHub Desktop.
with open('hahow_courses.json', 'r', encoding='utf-8') as f:
courses = json.load(f)
# 取出程式類課程的募資價/上線價/學生數,並顯示統計資料
pre_order_prices = list()
prices = list()
tickets = list()
lengths = list()
for c in courses:
if '55de81ac9d1fa51000f94770' in c['categories']:
pre_order_prices.append(c['preOrderedPrice'])
prices.append(c['price'])
tickets.append(c['numSoldTickets'])
lengths.append(c['totalVideoLengthInSeconds'])
print('程式類課程共有 %d 堂' % len(prices)) # 23
print('平均募資價:', np.mean(pre_order_prices)) # 719.09
print('平均上線價:', np.mean(prices)) # 1322.57
print('平均學生數:', np.mean(tickets)) # 483.22
print('平均課程分鐘:', np.mean(lengths)/60) # 515.12
corrcoef = np.corrcoef([tickets, pre_order_prices, prices, lengths])
print('募資價與學生數之相關係數: ', corrcoef[0, 1]) # 0.18
print('上線價與學生數之相關係數: ', corrcoef[0, 2]) # 0.36
print('課程長度與學生數之相關係數: ', corrcoef[0, 3]) # 0.65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment