question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pd.Timestamp.now() not mocked

See original GitHub issue

Code for replication:

import datetime
import pandas as pd
import freezegun

with freezegun.freeze_time("2011-01-01"):
    print(pd.Timestamp.now())
    print(datetime.datetime.now())

Expected output:

2011-01-01 00:00:00
2011-01-01 00:00:00

Actual output:

2019-05-20 17:14:03.781282
2011-01-01 00:00:00

Version information:

freezegun==0.3.11
pandas==0.24.1

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:9
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
rileypetersoncommented, Nov 27, 2019

+1 on this issue

2reactions
adamchainzcommented, Nov 28, 2021

This works in time-machine: https://pypi.org/project/time-machine/

(Built as an alternative to freezegun, history post)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to test pandas DataFrame with current timestamp
Then, you can use an assert statement to check if the two DataFrames are equal. import unittest import pandas as pd from unittest.mock...
Read more >
pandas.Timestamp.now — pandas 1.5.2 documentation
Return new Timestamp object representing current time local to tz. Parameters ... pd.Timestamp.now() Timestamp('2020-11-16 22:06:16.378782').
Read more >
How to Mock the Current Date and Time in Python
If you're testing Python code that relies on the current date or time, you will probably want to mock time to test different...
Read more >
Using pandas to_datetime with timestamps - GeeksforGeeks
The pd.to_datetime() method with a timestamp as argument and unit='ms', calculating the number of milliseconds to the Unix epoch start.
Read more >
Python Mock.timestamp Examples
Mock.timestamp extracted from open source projects. ... Timestamp(now - datetime.timedelta(hours=2)) strike2.timestamp = pd.Timestamp(now) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found