# How axis parameters pandas understanding? # Axis = 0 or "index": # If the operation is one-way, refers to a line # If the polymerization operation, referring to the cross rows interbank # Axis = 1 or "the Columns" # If a separate operation, it refers to a column # if it is aggregation operations, referring to the inter-row Cross the Columns # according to which axis, is this axis to move, the other axis remains move import pandas as pd import numpy as np df = pd.DataFrame( np.arange(12).reshape(3,4), columns = ["A","B","C","D"] ) # 1 single drop, is to delete a column df.drop ( " A " , Axis = 1 ) # 2 single-line drop, promptly remove a row df.drop (. 1, Axis = 0) # 3 according to axis = 0 / index mean polymerization operation performed # counter-intuitive: the result is not outputted per row, but the result of each column # axis=0 or axis = index df.mean(axis=0) # 4 press axis = 1 / columns mean polymerization operation performed df.mean (Axis =. 1 ) # In the example, a deeper understanding DEF get_sum_value (X): return X [ " A " ] + X [ " B " ] + X [ " C " ] + X [ " D " ] df["sum_value"] = df.apply(get_sum_value,axis=1) df
study hard, improve every day