我正在尝试将数据列转换为隔离数据。这是使用熊猫qcut:
# Get first column to quartile
firstCol = df.columns.get_loc(411.447817504) # Get column num of first wavelength
# We need the list of column titles.
cols = df.columns
# We loop through our 1100 columns to apply quartiling
for colLoc in range(0,1100):
# Print what column is being processed
print(f'Column {colLoc}')
column_name = cols[firstCol+colLoc]
# Generate and apply quartiling
df[column_name] = pd.qcut(df[column_name].astype('float'), 4, ['q1','q2','q3','q4'])
有什么办法可以加快这个过程?可能是通过使用np数组,然后一次将其处理到df中吗?