代码之家  ›  专栏  ›  技术社区  ›  Amelio Vazquez-Reina

随机数据帧

  •  3
  • Amelio Vazquez-Reina  · 技术社区  · 10 年前

    我经常发现自己需要创建随机(假的)DataFrame、多索引Dataframe和Series,其中的列包括 日期 、数字和字符串。

    Pandas是否提供了生成随机数据帧的机制?或者是否有任何特定的软件包可以帮助完成这项任务?

    1 回复  |  直到 10 年前
        1
  •  3
  •   behzad.nouri    10 年前

    也许是市场数据?

    >>> import pandas.io.data as web
    >>> web.DataReader(["AAPL", "GOOG"], "yahoo", start='2014-03-26').to_frame()
    
                         Open     High      Low    Close    Volume  Adj Close
    Date       minor                                                         
    2014-03-26 AAPL    546.52   549.00   538.86   539.78  10706000     539.78
               GOOG   1162.01  1171.57  1131.50  1131.97   2580000    1131.97
    2014-03-27 AAPL    540.02   541.50   535.12   537.46   7929700     537.46
               GOOG   1130.85  1131.94  1102.10  1114.28   3822200    1114.28
    2014-03-28 AAPL    538.32   538.94   534.25   536.86   7106900     536.86
               GOOG   1119.00  1133.19  1117.77  1120.15   2254700    1120.15
    2014-03-31 AAPL    539.23   540.81   535.93   536.74   5972100     536.74
               GOOG   1130.40  1135.00  1112.85  1114.51   1940500    1114.51
    
    [8 rows x 6 columns]