Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create test_timestamp_fromisoformat.py #56477

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def normalize_dictlike_arg(
and any(is_list_like(v) for _, v in func.items())
) or (any(is_dict_like(v) for _, v in func.items())):
# GH 15931 - deprecation of renaming keys
raise SpecificationError("nested renamer is not supported")
raise SpecificationError("nested renamer is not supported. Possible duplicate column names.")

if obj.ndim != 1:
# Check for missing columns on a frame
Expand Down
18 changes: 18 additions & 0 deletions pandas/tests/scalar/timestamp/test_timestamp_fromisoformat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pandas as pd
import pytest
# to test and assert that Timestamp.fromisoformat should return a timezone aware timestamp

def test_timestamp_fromisoformat_timezone_handling():
# Test case for ISO 8601 string with Zulu (UTC) timezone
timestr_utc = '2023-11-05T08:30:00Z'
ts_utc = pd.Timestamp.fromisoformat(timestr_utc)
assert ts_utc == pd.to_datetime(timestr_utc), "UTC timezone not handled correctly"

# Test case for ISO 8601 string with the offset timezone
timestr_offset = '2023-11-05T08:30:00+0000'
ts_offset = pd.Timestamp.fromisoformat(timestr_offset)
assert ts_offset == pd.to_datetime(timestr_offset), "Offset timezone not handled correctly"

# Test case for a roundtrip conversion
ts_now = pd.Timestamp.utcnow()
assert ts_now == pd.Timestamp.fromisoformat(ts_now.isoformat()), "Roundtrip conversion loses timezone information"
Loading