首页 > 其他 > 详细

Project 2

时间:2016-10-18 09:21:08      阅读:250      评论:0      收藏:0      [点我收藏+]

1. The way to create a DataFrame with its own index and certain columns.

  state_pop = pd.read_csv("state_population.csv") 

  counts = police_killings["state_fp"].value_counts() #get the value_counts() we need from certain DataFrame

  counts_index = counts.index.tolist() 

  state_index = np.arange(len(counts_index)) # Because we would like to put counts_index.index and counts_index.values as two columns in the DataFrame State. So we are going to get the number of counts_index.value and put them into a list. 

  state = pd.DataFrame({"STATE":counts.index,"Shootings":counts},index = state_index,) # To setup the index and two columns in the DataFrame

2. 

Project 2

原文:http://www.cnblogs.com/kingoscar/p/5971938.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!