[python] pandas study notes (eight) axis parameters

Insert picture description here
axis = 0 or index is a row, there are single or multiple rows
axis = 1 or columns are columns, it is single or multiple columns

import numpy as np
import pandas as pd

b = pd.DataFrame(
    np.arange(12).reshape(3, 4),
    columns=['A', 'B', 'C', 'D'],
    index=['a', 'b', 'c']
)

Insert picture description here

Delete a column

b = b.drop('A', axis=1)

Delete a row

b = b.drop('a', axis=0)

Find the mean of the ranks

c = b.mean(axis=0)
c = b.mean(axis=1)

axis=0 ->
Insert picture description here
axis=1 ->
Insert picture description here
Insert picture description here
axis=0, understood as getting the index of the row, only the row can be processed, the data in the row cannot be interacted

Guess you like

Origin blog.csdn.net/Sgmple/article/details/113069300