Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert all date columns using pd.datetime

def lookup(s):
    """
    This is an extremely fast approach to datetime parsing.
    For large data, the same dates are often repeated. Rather than
    re-parse these, we store all unique dates, parse them, and
    use a lookup to convert all dates.
    """
    dates = {date:pd.to_datetime(date) for date in s.unique()}
    return s.apply(lambda v: dates[v])

to_datetime: 5799 ms
dateutil:    5162 ms
strptime:    1651 ms
manual:       242 ms
lookup:        32 ms
Comment

PREVIOUS NEXT
Code Example
Python :: how to access python list 
Python :: Python soma números 
Python :: Window freezes after clicking of button in python GTK3 
Python :: python quick tutorial 
Python :: python sleep for 1 minute 
Python :: python loc id in list 
Python :: weigted average in pandas 
Python :: read past tense 
Python :: capiatlize first letter in list 
Python :: django date grater 
Python :: dataframe from function 
Python :: ax text relative coordinates 
Python :: REMOVE ALL ROWS FROM DATFRAME WGICH HAS DATA OLDER THAN 3 MONTHS PANDAS 
Python :: run django using nssm 
Python :: removeStopWords 
Python :: discord.py reply to message 
Python :: delete history django simple 
Python :: while my_input != "exit": 
Python :: calling function whose name is in a variable 
Python :: replace substrings to float 
Python :: correct code to read csv file in python 
Python :: how to make a function input optional in python 
Python :: /bin/sh: 1: python: not found code runner 
Python :: remove exif from image 
Python :: install cs50 library python 
Python :: how to get unknown wifi password using python 
Python :: import * with __import__ 
Python :: How to Add Elements to a dictionary using the update() method 
Python :: how to package a python library 
Python :: pandas get most occurring value for each id 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =