1. For searching certain row in certain column. We use name["column_name"][row_index] to locate the certain data in the DataFrame.

2. Pivot_table: Pivot_table is a powerful function that can create a new DataFrame according to the requirement of the data. 

  example:

  passenger_survival = titanic_survival.pivot_table(index="pclass", values=["age", "survived"], aggfunc=np.mean)# Here we use the pclass(1,2,3) in the titanic_survival DataFrame as the index. And we use the mean of age and survived people as values.

  print(passenger_survival)

3. Use .iloc[] function to locate the row and column value.  Use .loc[] to get the row and column index value.

4. Dropna() function delete the rows with missing number in certain column.

5. By default, apply() function will iterate each column in the Series and perform the function.

Example:

import pandas as pd

def null_count(column):
  column_null = pd.isnull(column)# This is the same as pd.isnull(titanic_survival.loc[0,:]), it is goes through each column but not each value in each column.
  null = column[column_null == True]
  return len(null)

6. For series x, x["a"] present the column a in series x. x[s] , s is the column of true/false. So x[s] represent the row which is Ture in the series.

7. Use iloc will return a number of an array instead of a series.

 

posted on 2016-10-07 01:56  阿难1020  阅读(156)  评论(0编辑  收藏  举报