使用官方安装程序在 macOS 11.6/Xcode 13 上安装新诗失败:
u@s-MacBook-Pro ~ % curl -sSL https://install.python-poetry.org | python3 -
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
/Users/u/Library/Python/3.8/bin
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.1.12): An error occurred. Removing partial environment. …Run Code Online (Sandbox Code Playgroud) 我一直在尝试安排异步函数。我的理解是,它将AsyncIOScheduler让我这样做,但在这个特定的代码块中,我没有得到任何快乐。
只需运行一个基本示例就没有问题:
from datetime import datetime
import asyncio
from apscheduler.schedulers.asyncio import AsyncIOScheduler
async def tick():
print(f"Tick! The async time is {datetime.now()}")
if __name__ == '__main__':
scheduler = AsyncIOScheduler()
scheduler.add_job(tick, 'interval', seconds=3)
scheduler.start()
try:
asyncio.get_event_loop().run_forever()
except (KeyboardInterrupt, SystemExit):
pass
Run Code Online (Sandbox Code Playgroud)
生产:
Tick! The async time is 2021-07-01 18:47:43.503460
Tick! The async time is 2021-07-01 18:47:46.500421
Tick! The async time is 2021-07-01 18:47:49.500208
^C%
Run Code Online (Sandbox Code Playgroud)
然而,我的代码块因有关可调用对象的各种问题而出错,并继续告诉我seed从未等待过。main()在设置调度程序之前,它会等待很好的调用,但也许这是一个转移注意力的事情?
我不是Python专家,所以请温柔点:)
预先感谢您提供任何线索。
import asyncio
from apscheduler.schedulers.asyncio import AsyncIOScheduler
import c_seed
import c_logging …Run Code Online (Sandbox Code Playgroud) 我有一个不断增长的数据框,并且我想定期检索最后一行。
# dbdf.info(memory_usage='deep')
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 6652 entries, 2022-10-23 17:15:00-04:00 to 2022-10-28 08:06:00-04:00
Freq: T
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 open 6592 non-null float64
1 high 6592 non-null float64
2 low 6592 non-null float64
3 close 6592 non-null float64
dtypes: float64(4)
memory usage: 259.8 KB
Run Code Online (Sandbox Code Playgroud)
数据帧并不占用很大的内存占用,但尽管如此,我想了解检索最后一行的最有效方法,以便我可以调用.to_dicts()最后一行。
我当然可以做一些天真的事情,比如:
bars = dbdf.to_dict(orient="records")
print(bars[-1])
Run Code Online (Sandbox Code Playgroud)
在这种特殊情况下,考虑到数据帧的大小可能很好,但如果数据帧的内存占用和行数大几个数量级,是否有更好的方法来实现相同的效果,也可以被认为是最好的方法无论数据框的足迹如何,常见的做法是什么?