Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

date component

def getMonth(s):
  return s.split("-")[1]

def getDay(s):
  return s.split("-")[0]

def getYear(s):
  return s.split("-")[2]

def getYearMonth(s):
  return s.split("-")[1]+"-"+s.split("-")[2]

df['year']= df['Date'].apply(lambda x: getYear(x))
df['month']= df['Date'].apply(lambda x: getMonth(x))
df['day']= df['Date'].apply(lambda x: getDay(x))
df['YearMonth']= df['Date'].apply(lambda x: getYearMonth(x))
Comment

PREVIOUS NEXT
Code Example
Python :: kivy lang 
Python :: ladnha; 
Python :: slug in redirect django 
Python :: run all jupyter notebooks in project folder 
Python :: get multiples of a number between two numbers python 
Python :: python plot auc 95% confidence intervals stackoverflow 
Python :: check accessability of the file 
Python :: read file in python 
Python :: generate-thumbnails-in-django-with-pil 
Python :: grepper how to use fraction 
Python :: improt kmean 
Python :: num = [7,8, 120, 25, 44, 20, 27] newnum = [] def remove_even(num): for i in num: if i%2 != 0: newnum.append(i) return newnum print("get_unevens") test(remove_even(num), [7,25,27]) 
Python :: Print in python capital p 
Python :: django validate_comma_separated_integer_list 
Python :: how ti maek a prinyt comnad i pyuthon 
Python :: loops with variables that count 
Python :: onetomany field 
Python :: same quotes in a quotes 
Python :: how to define an empyt dic tin python 
Python :: violajones python opencv 
Python :: imshow show nan as black 
Python :: import cv2 illegal instruction (core dumped) 
Python :: Higher-order functions and operations on callable objects in python 
Python :: how to print a character n times in python 
Python :: pandas merge validate 
Python :: re.split 
Python :: range() in python 
Python :: pandas append dataframes with same columns 
Python :: Adding new column to existing DataFrame in Pandas 
Python :: python3 list directories 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =