码迷,mamicode.com
首页 > 其他好文 > 详细

Project 2

时间:2016-10-18 09:24:03      阅读:143      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!