Add support of Hourly data to trafic_analysis
Browse files
apps/kpi_analysis/trafic_analysis.py
CHANGED
|
@@ -49,7 +49,10 @@ def preprocess_2g(df: pd.DataFrame) -> pd.DataFrame:
|
|
| 49 |
df["2g_data_trafic"] = ((df["TRAFFIC_PS DL"] + df["PS_UL_Load"]) / 1000).round(1)
|
| 50 |
df.rename(columns={"2G_Carried Traffic": "2g_voice_trafic"}, inplace=True)
|
| 51 |
df["code"] = df["BCF name"].apply(extract_code)
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
df["ID"] = df["date"].astype(str) + "_" + df["code"].astype(str)
|
| 54 |
df = df.groupby(["date", "ID", "code"], as_index=False)[
|
| 55 |
["2g_data_trafic", "2g_voice_trafic"]
|
|
@@ -60,7 +63,10 @@ def preprocess_2g(df: pd.DataFrame) -> pd.DataFrame:
|
|
| 60 |
def preprocess_3g(df: pd.DataFrame) -> pd.DataFrame:
|
| 61 |
df = df[df["WBTS name"].str.len() >= 10].copy()
|
| 62 |
df["code"] = df["WBTS name"].apply(extract_code)
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
| 64 |
df["ID"] = df["date"].astype(str) + "_" + df["code"].astype(str)
|
| 65 |
df.rename(
|
| 66 |
columns={
|
|
@@ -82,7 +88,10 @@ def preprocess_lte(df: pd.DataFrame) -> pd.DataFrame:
|
|
| 82 |
+ df["4G/LTE UL Traffic Volume (GBytes)"]
|
| 83 |
)
|
| 84 |
df["code"] = df["LNBTS name"].apply(extract_code)
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
| 86 |
df["ID"] = df["date"].astype(str) + "_" + df["code"].astype(str)
|
| 87 |
df = df.groupby(["date", "ID", "code"], as_index=False)[["lte_data_trafic"]].sum()
|
| 88 |
return df
|
|
|
|
| 49 |
df["2g_data_trafic"] = ((df["TRAFFIC_PS DL"] + df["PS_UL_Load"]) / 1000).round(1)
|
| 50 |
df.rename(columns={"2G_Carried Traffic": "2g_voice_trafic"}, inplace=True)
|
| 51 |
df["code"] = df["BCF name"].apply(extract_code)
|
| 52 |
+
date_format = (
|
| 53 |
+
"%m.%d.%Y %H:%M:%S" if len(df["PERIOD_START_TIME"].iat[0]) > 10 else "%m.%d.%Y"
|
| 54 |
+
)
|
| 55 |
+
df["date"] = pd.to_datetime(df["PERIOD_START_TIME"], format=date_format)
|
| 56 |
df["ID"] = df["date"].astype(str) + "_" + df["code"].astype(str)
|
| 57 |
df = df.groupby(["date", "ID", "code"], as_index=False)[
|
| 58 |
["2g_data_trafic", "2g_voice_trafic"]
|
|
|
|
| 63 |
def preprocess_3g(df: pd.DataFrame) -> pd.DataFrame:
|
| 64 |
df = df[df["WBTS name"].str.len() >= 10].copy()
|
| 65 |
df["code"] = df["WBTS name"].apply(extract_code)
|
| 66 |
+
date_format = (
|
| 67 |
+
"%m.%d.%Y %H:%M:%S" if len(df["PERIOD_START_TIME"].iat[0]) > 10 else "%m.%d.%Y"
|
| 68 |
+
)
|
| 69 |
+
df["date"] = pd.to_datetime(df["PERIOD_START_TIME"], format=date_format)
|
| 70 |
df["ID"] = df["date"].astype(str) + "_" + df["code"].astype(str)
|
| 71 |
df.rename(
|
| 72 |
columns={
|
|
|
|
| 88 |
+ df["4G/LTE UL Traffic Volume (GBytes)"]
|
| 89 |
)
|
| 90 |
df["code"] = df["LNBTS name"].apply(extract_code)
|
| 91 |
+
date_format = (
|
| 92 |
+
"%m.%d.%Y %H:%M:%S" if len(df["PERIOD_START_TIME"].iat[0]) > 10 else "%m.%d.%Y"
|
| 93 |
+
)
|
| 94 |
+
df["date"] = pd.to_datetime(df["PERIOD_START_TIME"], format=date_format)
|
| 95 |
df["ID"] = df["date"].astype(str) + "_" + df["code"].astype(str)
|
| 96 |
df = df.groupby(["date", "ID", "code"], as_index=False)[["lte_data_trafic"]].sum()
|
| 97 |
return df
|