text_plain_output_1.png image_output_1.png
import math

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

df = pd.read_csv('../input/renfe.csv')

df.isna().sum()

df.dropna(inplace=True)

df.drop(['Unnamed: 0'], axis=1, inplace=True)
df.drop(['insert_date'], axis=1, inplace=True)

f,ax = plt.subplots(figsize=(6, 6))
sns.heatmap(df.corr(), annot=True, cmap = "Blues", linewidths=.5, fmt= '.2f',ax = ax)
plt.show()

hr_cos = []
hr_sin = []
min_cos = []
min_sin = []
data = df['start_date'].values
for i in range(len(data)):
    time_obj = dt.datetime.strptime(data[i], '%Y-%m-%d %H:%M:%S')
    hr = time_obj.hour
    minute = time_obj.minute
    sample_hr_sin = math.sin(hr * (2.0 * math.pi / 24))
    sample_hr_cos = math.cos(hr * (2.0 * math.pi / 24))
    sample_min_sin = math.sin(minute * (2.0 * math.pi / 60))
    sample_min_cos = math.cos(minute * (2.0 * math.pi / 60))
    hr_cos.append(sample_hr_cos)
    hr_sin.append(sample_hr_sin)
    min_cos.append(sample_min_cos)
    min_sin.append(sample_min_sin)
df['depart_time_hr_sin'] = hr_sin
df['depart_time_hr_cos'] = hr_cos
df['depart_time_min_sin'] = min_sin
df['depart_time_min_cos'] = min_cos
hr_cos = []
hr_sin = []
min_cos = []
min_sin = []
data = df['end_date'].values
for i in range(len(data)):
    time_obj = dt.datetime.strptime(data[i], '%Y-%m-%d %H:%M:%S')
    hr = time_obj.hour
    minute = time_obj.minute
    sample_hr_sin = math.sin(hr * (2.0 * math.pi / 24))
    sample_hr_cos = math.cos(hr * (2.0 * math.pi / 24))
    sample_min_sin = math.sin(minute * (2.0 * math.pi / 60))
    sample_min_cos = math.cos(minute * (2.0 * math.pi / 60))
    hr_cos.append(sample_hr_cos)
    hr_sin.append(sample_hr_sin)
    min_cos.append(sample_min_cos)
    min_sin.append(sample_min_sin)
df['arrival_time_hr_sin'] = hr_sin
df['arrival_time_hr_cos'] = hr_cos
df['arrival_time_min_sin'] = min_sin
df['arrival_time_min_cos'] = min_cos