[RICAPP-173] AD xApp Release version 0.0.2 (Dawn)
[ric-app/ad.git] / ad / ad_model / tb_format.py
1 # ==================================================================================
2 #  Copyright (c) 2020 HCL Technologies Limited.
3 #
4 #  Licensed under the Apache License, Version 2.0 (the "License");
5 #  you may not use this file except in compliance with the License.
6 #  You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under the License is distributed on an "AS IS" BASIS,
12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #  See the License for the specific language governing permissions and
14 #  limitations under the License.
15 # ==================================================================================
16
17 import pandas as pd
18 from ad_model.processing import preprocess
19 import datetime
20
21 UEKeyList = ['MeasTimestampRF', 'UEPDCPBytesDL', 'UEPDCPBytesUL', 'UEPRBUsageDL', 'UEPRBUsageUL', 'S_RSRP', 'S_RSRQ', 'S_SINR', 'UEID']
22
23
24 def parse(df):
25     """
26       This block will be modified when we are going to fetch the data from database via sdl api.
27       start the preprocessing, processing steps using the keycolumns
28       populates the current timestamp value for MeasTimestampRF
29     """
30     df.index = range(df.shape[0])
31     df = df[UEKeyList]
32     db = preprocess(df)
33     df = db.process()
34     del db
35     df['MeasTimestampRF'] = pd.date_range(start=datetime.datetime.now(), periods=len(df), freq='-10ms')
36     return df