import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile
import time
import seaborn as sns
import matplotlib.pyplot as plt
import datetime
import numpy as np
df=pd.read_excel('currencynames.xlsx', sheet_name='Sheet1')
writer = pd.ExcelWriter('cryptodata.xlsx', engine='xlsxwriter')
currencies = df['Currency Name']
print(currencies[0])
for i in range(0,1465,1):
print("https://coinmarketcap.com/currencies/"+currencies[i]+"/historical-data/?start=20130428&end="+time.strftime("%Y%m%d"))
currency_market_info = pd.read_html("https://coinmarketcap.com/currencies/"+currencies[i].lower()+"/historical-data/?start=20130428&end="+time.strftime("%Y%m%d"))[0]
currency_market_info = currency_market_info.assign(Date=pd.to_datetime(currency_market_info['Date']))
currency_market_info.loc[currency_market_info['Volume']=="-",'Volume']=0
currency_market_info['Volume'] = currency_market_info['Volume'].astype('int64')
currency_market_info.head()
currency_market_info.to_excel(writer, sheet_name=currencies[i])
currency_market_info = 0
print("Done with "+currencies[i])
C:\用户\ SAU \ Anaconda3 \ lib中\站点包\大熊猫\核心\ ops.py:816: FutureWarning:元素比较失败;返回标量 相反,但将来会进行元素比较 result = getattr(x,name)(y)Traceback(最近一次调用last):
文件“”,第1行,in runfile('C:/ Users / SAU / Desktop / deep learning / cryptodata / data.py',wdir ='C:/ Users / SAU / Desktop / deep learning / cryptodata')
文件 “C:\用户\ SAU \ Anaconda3 \ LIB \站点包\ Spyder的\ utils的\网站\ sitecustomize.py” 第880行,在runfile中 execfile(filename,namespace)
文件 “C:\用户\ SAU \ Anaconda3 \ LIB \站点包\ Spyder的\ utils的\网站\ sitecustomize.py” 第102行,在execfile中 exec(compile(f.read(),filename,'exec'),namespace)
文件“C:/ Users / SAU / Desktop / deep learning / cryptodata / data.py”,行 19,在
currency_market_info.loc[currency_market_info['Volume']=="-",'Volume']=0
文件“C:\ Users \ SAU \ Anaconda3 \ lib \ site-packages \ pandas \ core \ ops.py”, 第879行,包装中 res = na_op(values,other)
文件“C:\ Users \ SAU \ Anaconda3 \ lib \ site-packages \ pandas \ core \ ops.py”, 第818行,在na_op中 引发TypeError(“无效的类型比较”)
TypeError:无效的类型比较