Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas remove timezone info

testdata['time'].dt.tz_localize(None)
Comment

remove timezone from column pandas

import pandas as pd
from datetime import datetime, timezone
 
# CREATE THE PANDAS DATAFRAME
# WITH TIMESTAMP COLUMN
df = pd.DataFrame({
    "orderNo": [
        "4278954",
        "3473895",
        "8763762",
        "4738289",
        "1294394"
    ],
    "timestamp": [
        datetime.strptime("2021-06-01",
                          "%Y-%m-%d").replace(tzinfo=timezone.utc),
        datetime.strptime("2021-06-02",
                          "%Y-%m-%d").replace(tzinfo=timezone.utc),
        datetime.strptime("2021-06-03",
                          "%Y-%m-%d").replace(tzinfo=timezone.utc),
        datetime.strptime("2021-06-04",
                          "%Y-%m-%d").replace(tzinfo=timezone.utc),
        datetime.strptime("2021-06-05",
                          "%Y-%m-%d").replace(tzinfo=timezone.utc)
    ]
})
 
# PRINT THE DATATYPES OF
# EACH COLUMN OF DATAFRAME
print(df.dtypes)
 
# VIEW THE DATAFRAME
print(df)
Comment

PREVIOUS NEXT
Code Example
Python :: how to create a superuser in django 
Python :: django no such table 
Python :: dict from two lists 
Python :: pandas drop unnamed columns 
Python :: pandas rename specific column 
Python :: how to capture a single photo with webcam opencv 
Python :: convert list of strings to ints python 
Python :: shutdown/restart windows with python 
Python :: python write text file 
Python :: python delete folder 
Python :: Extract images from html page based on src attribute using beatutiful soup 
Python :: pandas dropna specific column 
Python :: axis number size matplotlib 
Python :: select categorical columns pandas 
Python :: export data csv python 
Python :: get page source code selenium python 
Python :: index to datetime pandas 
Python :: pandas convert header to first row 
Python :: jalali date to gregorian date 
Python :: convert pandas series from str to int 
Python :: download python on wsl 
Python :: how to make my jupyter prin full array 
Python :: get longest shortest word in list python 
Python :: Update all packages using pip on Windows 
Python :: python all possible combinations of multiple lists 
Python :: create pandas dataframe with random numbers 
Python :: create dict from json file python 
Python :: python error get line 
Python :: how to read the first line in a file python 
Python :: check gpu in tensorflow 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =