遍历数据框的所有列以绘制所有列的散点图

Loop through all columns of dataframe to plot scatter plot for all columns

我的数据框有 6 列,我想针对其他列绘制每列的散点图,有没有办法遍历数据框的所有列来绘制散点图而不是手动选择 x 和 y?

例子

import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(100, 6), columns=['a', 'b', 'c', 'd', 'e', 'f'])
df.head()

# I don't want to manually select x and y instead, I am looking for automatically selecting one columns with another column

df.plot(kind='scatter', x='a', y='b', color='r')    
df.plot(kind='scatter', x='a', y='c', color='r')    
df.plot(kind='scatter', x='a', y='d', color='r')   
df.plot(kind='scatter', x='a', y='e', color='r')   
df.plot(kind='scatter', x='a', y='f', color='r') 

当然,您可以像这样遍历列

for column in df:
    print(df[column])