标签:
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.
标签:
原文地址:http://www.cnblogs.com/kingoscar/p/5971938.html