from datetime import datetime, timedelta
DATE_FORMAT = '%Y%m%d'
# show today with yyyymmdd format by string format time func
TODAY = datetime.today().strftime(DATE_FORMAT)
# convert string datetime to date obj by string parse time func
datetime_obj = datetime.strptime('20170111', DATE_FORMAT)
Delete a file which may not exist.
import os
try:
os.remove(filename)
except OSError:
pass
import os
if os.path.exists(path):
print ('File exist')
import glob
files = glob.glob('/path/to/files/*.txt')
for f in file:
print(f)
- Using set to subtract two list.
list(set(origin_all_feature_list) - set(remove_nan_feature_list))
import pandas as pd
path = 'data.csv'
### Import data without first column as header
data = pd.read_csv(path, header=None)
print data