Tuesday, 18 June 2019

Excel read, Two days different in Python


import pandas as pd
df = pd.read_excel('CompleteData2.xlsx', sheet_name='Test')
df.DOA = pd.to_datetime(df['DOA']).dt.normalize()
df.DOD = pd.to_datetime(df['DOD']).dt.normalize()
df['Length_of_stay'] =  ((df['DOD'] - df['DOA'])).dt.days
f = df.loc[:,['Length_of_stay']] 
mode = f.mode(axis=0)
print(mode, 'Mode of Length_of_stay')
mean = f.mean(axis=0)
print(mean, 'Mean of Length_of_stay')


No comments:

Post a Comment

SQL Query Table Name with Rows Counts

SELECT     TableName = t.NAME,     TableSchema = s.Name,     RowCounts = p.rows FROM     sys.tables t INNER JOIN     sys.schemas s ...