Automatic month

import pandas as pd
from datetime import date,timedelta
# # # # # # # # # # # # # # # # # 

def add_month (d, md): # md is ready to join in January how much
yd = md // 12 # more than 12 months, plus one year
m = d.month + md% 12 # If you add more than 12 months, in addition to what is this month + the remainder can
if m = 12:! # month added if not equal to 12
YD + = 12 // m
m m = 12%
return DATE (d.year + YD, m, d.day)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


# SkipRows = 5 title bar starting from the sixth row. usecols = "c: f" left A, B do not read row, column read column F dtype = { 'ID': str } from the ID column C is defined as STR
Books = pd.read_excel ( "out.xlsx", skiprows = 5, usecols = "c : f", dtype = { 'ID': str, ' sex': str, 'date': STR})
# Print (Books)
Start = dATE (2019,1,1)
for in books.index I:
Books [ 'ID'] AT [I] = I +. 1.
Books [ 'sex'] .at [i] = ' Yes'if i% 2 == 0 else "No"

# Books [ 'Date'] .at [i] = date (start.year + i, start.month, start.day) # this is to add in
books [ 'Date'] .at [i] = add_month (start , i) # this is a month plus a bit of difficulty # # # # # # # # # # # # # # # # # # # # # # # # # # #
Print (Books)
# 

Guess you like

Origin www.cnblogs.com/general-practitioner/p/12004684.html