zoukankan      html  css  js  c++  java
  • 014_散点图_直方图

    '''
    散点图:
        1 下图房屋面积(sqft_basement)与价格关系(price)
        
    直方图:
        1 下图房子集中在什么价位
        2 下图面积集中在什么面积
        
    密度图:
        1 下图房子多大概率70w
    '''
    
    
    import pandas as pd
    import matplotlib.pyplot as plt
    
    
    if __name__ == '__main__':
        # 显示设置 - 显示所有列
        pd.options.display.max_columns = 777
    
        homes = pd.read_excel("C:/Users/123/Desktop/pandas/014_散点图_直方图/home_data.xlsx")
        print(homes.columns)
        print(homes.head())
    
        # 散点图
        homes.plot.scatter(x = "price", y = "sqft_living")
        plt.show()
    
        homes.plot.scatter(x = "sqft_living", y = "price")
        plt.show()
    
    
        # 直方图 - 面积
        homes.sqft_living.plot.hist(bins=100)    # bins - 设置分布区间
        plt.xticks(range(0, max(homes.sqft_living), 500), fontsize = 8, rotation=90)
        plt.show()
    
        # 直方图 - 价格
        homes.price.plot.hist()  # bins - 设置分布区间
        plt.xticks(range(0, max(homes.price), 200000), fontsize=8, rotation=90)
        plt.show()
  • 相关阅读:
    MATLAB2019a安装
    每日日报6
    HTML表格
    HTML常见表单元素
    HTML特殊符号
    CTF-WEB:攻防世界-bug(综合应用)
    CTF-WEB:文件上传和 webshell
    CTF-WEB:BurpSuite 工具应用
    CTF-WEB:后台扫描与备份泄露
    CTF-WEB:PHP 伪协议
  • 原文地址:https://www.cnblogs.com/huafan/p/14409607.html
Copyright © 2011-2022 走看看