-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimestanp.py
93 lines (59 loc) · 1.93 KB
/
timestanp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
# coding: utf-8
# In[1]:
#First we import all the libraries
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from scipy import stats
from sklearn.utils import resample
import numpy as np
import pandas as pd
import datetime
import numpy as np
import pandas as pd
from mpl_toolkits.mplot3d import Axes3D
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt # plotting
import numpy as np # linear algebra
import os # accessing directory structure
import pandas as pd # data processing
from pandas.plotting import scatter_matrix
# In[1]:
from platform import python_version
print(python_version())
# In[4]:
df = pd.read_csv('E:/work/Supermicro/modeling/rsd_node_20211228_15.csv')
# In[294]:
# new data frame with split value columns
new = df["date"].str.split(".", n = 1, expand = True)
# making separate first name column from new data frame
df["Timestamp"]= new[0]
# making separate last name column from new data frame
df["micro_sec"]= new[1]
# Dropping old Name columns
df.drop(columns =["date"], inplace = True)
df.drop(columns =["micro_sec"], inplace = True)
# filter Timestamp alone
df = df[df['Timestamp'] != 'date']
# convert Timestamp
df['Timestamp'] = pd.to_datetime(df['Timestamp'])
#df['Timestamp'] = pd.to_datetime(df['Timestamp'], unit='s')
# In[295]:
df
# In[296]:
# CREATE VALIDATION DATA
pd.Timestamp('now') - pd.Timedelta(10, 'minutes')
# Use this if the timestamp is the index of the DataFrame
last_ts = df.Timestamp.iloc[-1]
last_ts = df["Timestamp"].iloc[-1]
# IMPORTANT : you need to change only below line not require to change in all the line
first_ts = last_ts - pd.Timedelta(15, 'minutes')
# Use this if the Timestamp is in a column
validation_data = df[df["Timestamp"] >= first_ts]
# Use this if the Timestamp is the index of the DataFrame
validation_data = df[df.Timestamp >= first_ts]
# In[297]:
validation_data
# In[ ]: