INNER CODE UNIT · Python

load_parquet_with_datetime

pgalko/BambooAI · web_app/app.py:447

def load_parquet_with_datetime(file_path):
    # Read the Parquet file
    df = pd.read_parquet(file_path)

    # Function to parse datetime and remove timezone
    def parse_and_remove_tz(series):
        return pd.to_datetime(series, format='%Y-%m-%d %H:%M:%S%z', utc=True).dt.tz_localize(None)

    # Iterate through columns and apply vectorized parsing where appropriate
    for col in df.columns:
        if pd.api.types.is_datetime64_any_dtype(df[col]):
            # Try to parse the column as datetime
            try:
                df[col] = parse_and_remove_tz(df[col])
            except ValueError:
                # If parsing fails, leave the column as is
                pass

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…