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 :: select first row of every group pandas 
Python :: beautifulsoup find element containing text 
Python :: class views django slug 
Python :: menu extension in mit app inventor 
Python :: selenium python element id 
Python :: how to print multiple integers in python in different line 
Python :: python for loop inside list 
Python :: ValueError: tuple.index(x): x not in tuple 
Python :: c is better than python 
Python :: show only lower diagonal in sns pairplot 
Python :: utils/decorators.py", line 11, in __get__ raise AttributeError("This method is available only on the class, not on instances.") AttributeError: This method is available only on the class, not on instances. 
Python :: function TBone() if 2=2 then print("Sup") end 
Python :: networkx - remove small components from a graph 
Python :: extract x y coordinates from image in pdf python 
Python :: python copy formula ghseets 
Python :: python converter to c 
Python :: flatten a list of lists python 
Shell :: FirewallD is not running 
Shell :: yarn emojis 
Shell :: linux how to see ports in use 
Shell :: how to restart nginx 
Shell :: conda install keras 
Shell :: remove all the containers docker 
Shell :: run disk usage analyzer as root ubuntu 20.04 
Shell :: windows flush dns 
Shell :: nginx stop commands 
Shell :: linux list files by size mb 
Shell :: install apt-cyg 
Shell :: bison install ubuntu 
Shell :: Amazon Linux 2 AMI install docker 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =