Add utility to convert XAUUSD time column format - #17
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| # Parse dates and drop timezone info if present, then format like 'YYYY-MM-DD HH:MM:SS' | ||
| times = pd.to_datetime(df['time']) | ||
| times = times.dt.tz_localize(None) # Remove timezone if it exists | ||
| df['time'] = times.dt.strftime('%Y-%m-%d %H:%M:%S') |
There was a problem hiding this comment.
[P1] Guard tz-localization for timezone-naive inputs
The conversion unconditionally applies times.dt.tz_localize(None). Pandas raises TypeError: Already tz-naive, use tz_localize to localize when the series has no timezone information, so the tool fails for CSVs that are already in the desired YYYY-MM-DD HH:MM:SS format. Handling naive timestamps (e.g. by using tz_convert(None) or wrapping the call in a try/except) would let the script safely normalize both timezone-aware and timezone-free files.
Useful? React with 👍 / 👎.
Summary
convert_time_format.pyto strip timezone information and format times likeXAUUSD_data.csvREADME.mdTesting
python convert_time_format.py XAUUSD_data_10min.csvhttps://chatgpt.com/codex/tasks/task_e_68c0a472c3f4832895ed4afde5c03765