标签: pendulum

让Pandas与Pendulum合作

我最近偶然发现了一个新的令人敬畏的pendulum,可以更轻松地使用日期时间.

pandas,有这个方便的to_datetime()方法允许将系列和其他对象转换为日期时间:

raw_data['Mycol'] = pd.to_datetime(raw_data['Mycol'], format='%d%b%Y:%H:%M:%S.%f')
Run Code Online (Sandbox Code Playgroud)

创建自定义to_<something>方法的规范方法是什么- 在这种情况下to_pendulum(),能够将一系列日期字符串直接转换为Pendulum对象的方法

这可能导致Series具有各种有趣的功能,例如,将一系列日期字符串转换为一系列"从现在开始的偏移" - 人类日期时间差异.

python datetime date pandas pendulum

13
推荐指数
1
解决办法
1228
查看次数

如何将钟摆转换为 datetime.datetime 类型?

在系统 pendulum v1.4 的当前部分中使用,但使用 croniter 它会导致https://github.com/sdispater/pendulum/issues/214 中描述的错误

这适用于 datetime.datetime 类型,我仍然必须使用 pendulum v1.4。

所以我正在寻找如何有效地将钟摆转换为 datetime.datetime 类型的解决方案?

已经尝试将钟摆格式化为字符串并使用 dateutil.parser 进行解析。

python datetime pendulum

8
推荐指数
2
解决办法
1万
查看次数

无法在 python3.7-alpine docker 镜像上安装 pendulum

我正在尝试在基于 python37-alpine 的 docker 映像中安装 pendulum 2.0.5,但它给了我以下错误:

\n\n
Installing dependencies from Pipfile.lock (0157fa)\xe2\x80\xa6\nAn error occurred while installing pendulum==2.0.5 --hash=sha256:1cde6e3c6310fb882c98f373795f807cb2bd6af01f34d2857e6e283b5ee91e09 --hash=sha256:485aef2089defee88607d37d5bc238934d0b90993d7bf9ceb36e481af41e9c66 --hash=sha256:57801754e05f30e8a7e4d24734c9fad82c6c3ec489151555f0fc66bb32ba6d6d --hash=sha256:7ee344bc87cb425b04717b90d14ffde14c1dd64eaa73060b3772edcf57f3e866 --hash=sha256:c460f4d8dc41ec3c4377ac1807678cd72fe5e973cc2943c104ffdeaac32dacb7 --hash=sha256:d3078e007315a959989c41cee5cfd63cfeeca21dd3d8295f4bc24199489e9b6c! Will try again.\nInstalling initially failed dependencies\xe2\x80\xa6\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1874, in do_install\n[pipenv.exceptions.InstallError]:       keep_outdated=keep_outdated\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1253, in do_init\n[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 859, in do_install_dependencies\n[pipenv.exceptions.InstallError]:       retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 763, in batch_install\n[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)\n[pipenv.exceptions.InstallError]:   File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 681, in _cleanup_procs\n[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)\n[pipenv.exceptions.InstallError]: [\'Collecting pendulum==2.0.5\', \'  Using cached …
Run Code Online (Sandbox Code Playgroud)

alpine-linux python-3.7 pendulum

5
推荐指数
1
解决办法
3721
查看次数

气流 initdb:无法从“pendulum”导入名称“Pendulum”

我在名为 engdados 的 Anaconda 环境之一中安装了气流。当我执行命令 airflow initdb 时,出现以下错误:airflow initdb: cannot import name 'Pendulum' from 'pendulum'。完整的回溯如下所示:

(engdados) guilherme@Athena-LNX:~$ airflow initdb
Traceback (most recent call last):
  File "/home/guilherme/anaconda3/envs/engdados/bin/airflow", line 25, in <module>
    from airflow.configuration import conf
  File "/home/guilherme/anaconda3/envs/engdados/lib/python3.8/site-packages/airflow/__init__.py", line 47, in <module>
    settings.initialize()
  File "/home/guilherme/anaconda3/envs/engdados/lib/python3.8/site-packages/airflow/settings.py", line 403, in initialize
    configure_adapters()
  File "/home/guilherme/anaconda3/envs/engdados/lib/python3.8/site-packages/airflow/settings.py", line 319, in configure_adapters
    from pendulum import Pendulum
ImportError: cannot import name 'Pendulum' from 'pendulum' (/home/guilherme/anaconda3/envs/engdados/lib/python3.8/site-packages/pendulum/__init__.py)
(engdados) guilherme@Athena-LNX:~$ service start mysql$
start: unrecognized service
(engdados) guilherme@Athena-LNX:~$ service mysql …
Run Code Online (Sandbox Code Playgroud)

airflow pendulum

4
推荐指数
1
解决办法
5163
查看次数

如何用钟摆创建时间增量?

我正在寻找一种timedelta用钟摆创建任意兼容对象的方法。以前有一种pendulum.interval方法,但在最新版本的 pendulum 中似乎不存在。

假设我想要五分钟的增量:肯定有一种方法可以比创建两个日期时间对象并减去它们更优雅吗?理想情况下我想说:pendulum.timedelta(minutes=5)

pendulum

0
推荐指数
1
解决办法
3476
查看次数

标签 统计

pendulum ×5

datetime ×2

python ×2

airflow ×1

alpine-linux ×1

date ×1

pandas ×1

python-3.7 ×1