我需要从导入的模块中提取5000个结果,但如果我甚至尝试返回1000个结果,我会得到一个错误。我最多能返回500个结果(num_players=500
)。理想情况下,我可以随机抽取5000个结果,但我想前5000个必须这样做。我只需要样本数据在Excel中运行分析。下面的代码取自此处文档中的一个示例https://pyett.readthedocs.io/en/latest/cohort.html
是否有人对我如何使其正确运行有任何建议?为什么它会失去与数据库的连接
from pyETT import ett
import pandas as pd
lb_cohort = ett.Cohort(ett.ETT().get_leaderboard(num_players=1000))
lb_cohort.size
df = lb_cohort.players_dataframe()
print(df)
file_name = 'export_file.xlsx'
df.to_excel(file_name)
print('DataFrame is written to Excel File successfully.')
这是我得到的例外:
Message=Cannot connect to host www.elevenvr.club:443 ssl:default [The semaphore timeout period has expired]
Source=C:\Users\Apache Paint\source\repos\Patrick_Kimble \Patrick_Kimble.py
StackTrace:
File "C:\Users\Apache Paint\source\repos\Patrick_Kimble\Patrick_Kimble.py", line 7, in (Current frame)
lb_cohort = ett.Cohort(ett.ETT().get_leaderboard(num_players=1000))
HTTPSConnectionPool(host='www.elevenvr.club', port=443): Max retries exceeded with url: /accounts/search/bensnow/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000025564B9AE20>: Failed to establish a new connection: [WinError 10060]
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))
编辑:
我创建了一个循环,试图从数据库中提取所有数据
for i in range(1, 500000):
try:
if int(i) % 100 == 0:
print('Loop is at:', i)
user_id = i
line = ett.ett_parser.get_user(user_id)
temp_df = pd.DataFrame(line, index=[i])
self.df_master = self.df_master.append(temp_df, ignore_index = True)
except Exception:
print("Error:",i )
MDR的答案是返回随机数据。但我需要使用describe()
函数来提取更多其他细节,但它只接受“队列”类型
例如:
import pandas as pd
lb_cohort = ett.Cohort(ett.ETT().get_leaderboard(num_players=10))
lb_cohort.size
lb_cohort.describe()
应该返回类似下图的内容
因为
.user_search_dataframe()
接受一个字符串并基于部分匹配返回一个帧,所以您可以组成一个长的用户名列表,循环它,然后将这些帧连接在一起示例:
输出(基于代码中的长列表):
相关问题 更多 >
编程相关推荐