Panda error in modifying line name index does not support mutable operations

During the panda data operation, two tricks appear during expansion:

Using data_PD. Append(), when expanding data in rows, the row names need to be the same in order to realize automatic expansion and use data_ PD. Columns = [], when modifying the row name, slicing is not allowed, and only a list can be created according to the original data length for assignment modification

# Iterate through different individual data and perform data stitching
response_pd = pd.DataFrame() # Create an empty panda
for ii in range(100, 106):
    sub = 'Sub%d'%ii
    index = np.where((np.array(filter_pd[sub+'_fg'])!=-100)&
    col_index =list(range(2, 7))+list(range(8, 20))+[23+ii*4,21+ii*4,22+ii*4]
    # Filter the data in the specified row
    temp_pd=filter_pd.iloc[index].iloc[:, col_index]
    ## Modify the row names, note that the slicing operation is not allowed here, only the original data length, create a list to assign values
    temp_pd.columns = list(temp_pd.columns)[:-3]+['first glance', 'first RT', 'last RT']
    # Expand the rows, note that you need the same row name to expand the data for the corresponding row
    response_pd = response_pd.append(temp_pd,
    print('table shape',response_pd.shape)

Read More: