我的資料框有 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')
uj5u.com熱心網友回復:
當然,您可以像這樣遍歷列
for column in df:
print(df[column])
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/451511.html
標籤:Python 熊猫 数据框 matplotlib 散点图
下一篇:真實和虛構的情節
