• Kaggle_Data Visualization of Bar Charts and Heatmaps


    step0 activate bar charts and heatmaps

    载入库文件

    import pandas as pd
    pd.plotting.register_matplotlib_converters()
    import matplotlib.pyplot as plt
    %matplotlib inline
    import seaborn as sns
    print("Setup Complete")

    设置代码检测

    # Set up code checking
    import os
    if not os.path.exists("../input/ign_scores.csv"):
        os.symlink("../input/data-for-datavis/ign_scores.csv", "../input/ign_scores.csv") 
    from learntools.core import binder
    binder.bind(globals())
    from learntools.data_viz_to_coder.ex3 import *
    print("Setup Complete")

    载入数据

    ign_filepath="../inputs/ign_scores.csv"
    ign_data=pd.read_csv(ign_filepath,index_col="Platform",parse_dates=True)
    step_1.check()

    step2 review the data

    print the data

    print(ign_data) # Your code here

    取出数据,做测验并check

    # Fill in the line below: What is the highest average score received by PC games,
    # for any platform?
    high_score = 7.759930
    
    # Fill in the line below: On the Playstation Vita platform, which genre has the 
    # lowest average score? Please provide the name of the column, and put your answer 
    # in single quotes (e.g., 'Action', 'Adventure', 'Fighting', etc.)
    worst_genre = 'Simulation'
    
    # Check your answers
    step_2.check()

    step3 pick up the best platform

    create a bar chart

    plt.figure(figsize=(12,6))
    sns.barplot(x=ign_data["Racing"],y=ign_data.index)
    plt.title("X_label")
    step_3.a.check()

    step4 all possible combination

    heatmap预备知识

    import numpy as np
    import seaborn as sns
    
    data = np.array([[1,2,3],[4,5,6],[7,8,9]])
    sns.heatmap(data,annot=True)

    # Heatmap showing average game score by platform and genre
    plt.figure(figsize=(10,10))
    sns.heatmap(ign_data,annot=True)
    plt.xlabel("Genre")
    plt.title("Average Game Score, by Platform and Genre")
    # Check your answer step_4.a.check()

  • 相关阅读:
    Session机制详解及分布式中Session共享解决方案
    分布式事务解决方案及实现
    MYSQL学习之安装、主从复制、读写分离原理解析以及详细配置(MySQL5.7)
    MySQL常见问题集锦及注意事项
    MySQL学习之索引机制详解(B+树)
    最全排序算法原理解析、java代码实现以及总结归纳
    判断某一点是否在几何图形内部
    .net项目dll内嵌加载
    WPF实现分页控件
    .net实现网易云音乐下载
  • 原文地址:https://www.cnblogs.com/yuyukun/p/12878291.html
Copyright © 2020-2023  润新知