zoukankan      html  css  js  c++  java
  • pandas 可视化

    import pandas as pd
    import numpy as np
    np.set_printoptions(threshold=np.inf)
    
    #生成一个二维数组,第一列为日期,第二列为正态分布值
    ts = pd.Series(np.random.randn(1000),index=pd.date_range('1/1/2000', periods=1000))
     
    #对值进行累加
    ts = ts.cumsum()
    
    #展现变量的趋势变化二维线画图函数
    #ts.plot()
    
    ts.plot(color='green', marker='.', linestyle='dashed', linewidth=1, markersize=6)

    生成可视化的图片:

                        ts.plot()                                        ts.plot(color='green', marker='.', linestyle='dashed', linewidth=1, markersize=6)
    
    

    DataFrame 的 plot()

    import pandas as pd
    import numpy as np
    np.set_printoptions(threshold=np.inf)
    import matplotlib.pyplot as plt
    
    
    #生成一个二维数组,第一列为日期,第二列为正态分布
    ts = pd.Series(np.random.randn(1000),index=pd.date_range('1/1/2000', periods=1000))
     
    #对值进行累加
    ts = ts.cumsum()
    
    #DataFrame 的 plot()
    df = pd.DataFrame(np.random.randn(1000, 4), index=ts.index,columns=['A', 'B', 'C', 'D'])
    print (df)
    
    #对值进行累加
    df = df.cumsum()
    
    #展现变量的趋势变化二维线画图函数
    plt.figure(figsize=(4,3),facecolor='blue');
    df.plot();

    生成的图:

    扩展:

    https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html#visualization

  • 相关阅读:
    Jquery
    JavaScript
    poj--2115 C Looooops
    poj--3970 party
    poj 1061 青蛙的约会
    hdu1250--Hat's Fibonacci
    2318--TOYS
    扩展欧几里得--让你一次刷个够
    关于大数加法的解法
    有关环形数组的约瑟夫问题
  • 原文地址:https://www.cnblogs.com/hello-wei/p/13608773.html
Copyright © 2011-2022 走看看