Open Guo-Zhang opened 7 years ago
Member List: √ Li Liu √ Yuyang Li √ Xingyu Zhu √ Zedong Hao √ Hao Jiang Weiran Li √ Hanlin Tang Zhiruo Wang Tian Xie √ Zhongxin Yue Yilin Zhang √ Yunfeng Zhou √ Jianwei Zhuang
import numpy as np
import pandas as pd
# 二项分布数组
arr = np.random.binomial(1, 0.5, size = (26,4))
# 大于0.5的数字
arr2 = arr[arr>0.5]
# 转化为dataframe
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
df = pd.DataFrame(arr, index = letters, columns = ['one','two','three','four'])
# 按照two的降序排列 取前五个
df2 = df.sort_values(['two'], ascending = False).iloc[0:5,:]
# 取 one 列
one = df['one']
oneMean = one.mean()
oneSum = one.sum()
oneMid = one.median()
oneVar = one.var()
@AustinJiangH Very good! Try to use Pythonic way to get 26 letters. You can try string
standard package in Python.
Please submit your homework for Lecture 1 of Python Data Analysis on 2017-07-06 here.