当大小为24022并且类型为bid时,我希望能够将特定日期绘制为x值,将大小绘制为y值。我尝试了以下方法:
headers = ['ticker','size','price','unix','type','date']
dtypes = {'ticker': 'str','size': 'int','price': 'float','unix': 'float','type': 'str','date': 'str'}
parse_dates = ['date']
btcnow = pd.read_csv('new 1031-113.csv',header=None,names=headers,dtype=dtypes,parse_dates=parse_dates)
#btc105=pd.read_excel('11-3-11-5 data.xlsx',sheet_name="Sheet1",header=None)
#btc103=btc103.append(btc105,ignore_index = True)
now3 = pd.DataFrame(btcnow,columns=['size','date','type'])
now4 = pd.DataFrame(btcnow,columns=['date','price'])
x1 = now3.loc[now3["size"] == 24022 & now3["type"]=='BID',"date"]
y1 = now3.loc[now3["size"] == 24022 & now3["type"]=='BID',"size"]
但是x1和y1给我一个错误:“无法比较类型为[bool]的标量的dtyped [object]数组” 这是now3数据框的样子:
size date type
0 200 2019-10-31 15:06:00 ASK
1 11000 2019-10-31 15:06:00 ASK
2 1 2019-10-31 15:06:00 BID
3 1 2019-10-31 15:06:00 ASK
4 10000 2019-10-31 15:06:00 ASK
... ... ... ...
1048570 1575 2019-11-03 02:42:00 ASK
1048571 4 2019-11-03 02:42:00 BID
1048572 120 2019-11-03 02:42:00 ASK
1048573 4 2019-11-03 02:42:00 BID
1048574 7472 2019-11-03 02:42:00 ASK