我正试图使用pandas_datareader.data
从雅虎获得股票数据,但我一直得到缺失的部分数据。这是我编码的。我现在想做的就是返回开始和结束日期之间的所有数据
import pandas as pd
import pandas_datareader.data as web
from datetime import datetime
ibm = web.DataReader('IBM', 'yahoo', datetime(2015,1,1)
datetime(2016,1,1))
现在这是返回这个:
数据
我很困惑,当我试图创建我的集合时,为什么我会得到带有所有缺失数据的椭圆。任何帮助都将不胜感激!
这就是pandas
显示结果的方式(如下所述)。pandas
省略了超过pd.set_option('max_rows', X)
设置的行(我认为default
是50)。您可以使用pd.options.display.max_rows
查看限制。
尝试ibm.info()
,您应该会看到显示的行数多于显示的行。
您的查询结果为:
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 252 entries, 2015-01-02 to 2015-12-31
Data columns (total 6 columns):
Open 252 non-null float64
High 252 non-null float64
Low 252 non-null float64
Close 252 non-null float64
Volume 252 non-null int64
Adj Close 252 non-null float64
dtypes: float64(5), int64(1)
memory usage: 13.8 KB
None
但显示为(尽管省略,但底部不是rows x columns
信息):
Open High Low Close Volume
Date
2015-01-02 161.309998 163.309998 161.000000 162.059998 5525500
2015-01-05 161.270004 161.270004 159.190002 159.509995 4880400
2015-01-06 159.669998 159.960007 155.169998 156.070007 6146700
2015-01-07 157.199997 157.199997 154.029999 155.050003 4701800
2015-01-08 156.240005 159.039993 155.550003 158.419998 4236800
2015-01-09 158.419998 160.339996 157.250000 159.110001 4484800
2015-01-12 159.000000 159.250000 155.759995 156.440002 4182800
2015-01-13 157.259995 159.970001 155.679993 156.809998 4377500
2015-01-14 154.860001 156.490005 153.740005 155.800003 4690300
2015-01-15 156.690002 156.970001 154.160004 154.570007 4248400
2015-01-16 153.820007 157.630005 153.820007 157.139999 5756000
2015-01-20 156.699997 157.330002 154.029999 156.949997 8392800
2015-01-21 153.029999 154.500000 151.070007 152.089996 11897100
2015-01-22 151.940002 155.720001 151.759995 155.389999 6120100
2015-01-23 155.029999 157.600006 154.889999 155.869995 4834800
2015-01-26 158.259995 159.460007 155.770004 156.360001 7888100
2015-01-27 154.940002 155.089996 152.589996 153.669998 5659600
2015-01-28 154.000000 154.529999 151.550003 151.550003 4495900
2015-01-29 151.380005 155.580002 149.520004 155.479996 8320800
2015-01-30 153.910004 155.240005 153.039993 153.309998 6563600
2015-02-02 154.000000 154.660004 151.509995 154.660004 4712200
2015-02-03 154.750000 158.600006 154.750000 158.470001 5539400
2015-02-04 157.210007 158.710007 156.699997 156.960007 3678500
2015-02-05 157.289993 158.589996 157.149994 157.910004 5253600
2015-02-06 157.339996 158.080002 156.229996 156.720001 3225000
2015-02-09 156.000000 157.500000 155.399994 155.750000 3057700
2015-02-10 156.740005 158.559998 155.080002 158.559998 4440600
2015-02-11 157.759995 159.089996 157.169998 158.199997 3626700
2015-02-12 158.720001 159.500000 158.089996 158.520004 3333100
2015-02-13 158.779999 160.800003 158.639999 160.399994 3706900
... ... ... ... ... ...
2015-11-18 134.789993 135.910004 134.259995 135.820007 4149200
2015-11-19 136.210007 137.740005 136.009995 136.740005 4753600
2015-11-20 137.369995 138.919998 137.250000 138.500000 5176400
2015-11-23 138.529999 138.869995 137.119995 138.460007 5137900
2015-11-24 137.649994 139.339996 137.309998 138.600006 3407700
2015-11-25 138.369995 138.429993 137.380005 138.000000 3238200
2015-11-27 138.000000 138.809998 137.210007 138.460007 1415800
2015-11-30 138.610001 139.899994 138.520004 139.419998 4545600
2015-12-01 139.580002 141.399994 139.580002 141.279999 4195100
2015-12-02 140.929993 141.210007 139.500000 139.699997 3725400
2015-12-03 140.100006 140.729996 138.190002 138.919998 5909600
2015-12-04 138.089996 141.020004 137.990005 140.429993 4571600
2015-12-07 140.160004 140.410004 138.809998 139.550003 3279400
2015-12-08 138.279999 139.059998 137.529999 138.050003 3905200
2015-12-09 137.380005 139.839996 136.229996 136.610001 4615000
2015-12-10 137.029999 137.850006 135.720001 136.779999 4222300
2015-12-11 135.229996 135.440002 133.910004 134.570007 5333800
2015-12-14 135.309998 136.139999 134.020004 135.929993 5143800
2015-12-15 137.399994 138.970001 137.279999 137.789993 4207900
2015-12-16 139.119995 139.649994 137.789993 139.289993 4345500
2015-12-17 139.350006 139.500000 136.309998 136.750000 4089500
2015-12-18 136.410004 136.960007 134.270004 134.899994 10026100
2015-12-21 135.830002 135.830002 134.020004 135.500000 5617500
2015-12-22 135.880005 138.190002 135.649994 137.929993 4263800
2015-12-23 138.300003 139.309998 138.110001 138.539993 5164900
2015-12-24 138.429993 138.880005 138.110001 138.250000 1495200
2015-12-28 137.740005 138.039993 136.539993 137.610001 3143400
2015-12-29 138.250000 140.059998 138.199997 139.779999 3943700
2015-12-30 139.580002 140.440002 139.220001 139.339996 2989400
2015-12-31 139.070007 139.100006 137.570007 137.619995 3462100
Adj Close
Date
2015-01-02 153.863588
2015-01-05 151.442555
2015-01-06 148.176550
2015-01-07 147.208134
2015-01-08 150.407687
2015-01-09 151.062791
2015-01-12 148.527832
2015-01-13 148.879114
2015-01-14 147.920202
2015-01-15 146.752415
2015-01-16 149.192426
2015-01-20 149.012033
2015-01-21 144.397834
2015-01-22 147.530934
2015-01-23 147.986654
2015-01-26 148.451876
2015-01-27 145.897925
2015-01-28 143.885151
2015-01-29 147.616379
2015-01-30 145.556132
2015-02-02 146.837859
2015-02-03 150.455161
2015-02-04 149.021536
2015-02-05 149.923486
2015-02-06 149.837432
2015-02-09 148.910029
2015-02-10 151.596622
2015-02-11 151.252431
2015-02-12 151.558385
2015-02-13 153.355812
... ...
2015-11-18 133.161622
2015-11-19 134.063613
2015-11-20 135.789160
2015-11-23 135.749949
2015-11-24 135.887208
2015-11-25 135.298946
2015-11-27 135.749949
2015-11-30 136.691151
2015-12-01 138.514746
2015-12-02 136.965669
2015-12-03 136.200937
2015-12-04 137.681377
2015-12-07 136.818611
2015-12-08 135.347970
2015-12-09 133.936153
2015-12-10 134.102824
2015-12-11 131.936088
2015-12-14 133.269455
2015-12-15 135.093050
2015-12-16 136.563691
2015-12-17 134.073412
2015-12-18 132.259616
2015-12-21 132.847878
2015-12-22 135.230309
2015-12-23 135.828370
2015-12-24 135.544053
2015-12-28 134.916580
2015-12-29 137.044105
2015-12-30 136.612715
2015-12-31 134.926379
[252 rows x 6 columns]