You are on page 1of 1

Sure, let's break down the program step by step:

Import Libraries:
The program starts by importing the necessary libraries, specifically
pandas for data manipulation and os for handling file paths.

Set Folder Path:


The folder_path variable is set to the directory where the Excel files are
located. This is the folder from which the program will read the input files and
where it will save the output file.

Merge Excel Files:


An empty DataFrame combined_df is created to store the combined data from
all Excel files.
The program iterates through each file in the specified folder.
If a file has a ".xlsx" extension, it is read using pd.read_excel() and
appended to combined_df.

Convert Columns to Numeric:


Two specific columns, namely 'RRC Connection Success Rate(All) (%)' and
'Packet Loss rate (UL)-VOLTE', are converted to numeric data types using
pd.to_numeric(). This is necessary to perform numerical operations and comparisons
later.

Filter RRC Connection Success Rate:


The combined_df DataFrame is grouped by 'SSA', 'Site Id', and 'Cell Id'.
The filter() function is used with a lambda function to filter out rows
where the 'RRC Connection Success Rate(All) (%)' column is less than 90% for all
rows within each group.
The filtered DataFrame is sorted by 'SSA', 'Site Id', and 'Cell Id'.

Filter Data Volume:


Similar to the previous step, the combined_df DataFrame is grouped and
filtered to include only rows where the 'Data Volume - Total (GB)' column is less
than 5 for all rows within each group.
The resulting DataFrame is sorted.

Filter Packet Loss Rate:


Again, the DataFrame is grouped and filtered to retain rows where the
'Packet Loss rate (UL)-VOLTE' column is greater than 3 for all rows within each
group.
The resulting DataFrame is sorted.

Write Filtered Data to Text File:


The program creates a new text file named 'filtered_sites.txt' in the
specified folder.
It writes the filtered data to this file, first the RRC filtered sites,
then volume filtered sites, and finally loss filtered sites.
Each section is separated by a line of dashes for clarity.

Confirmation Message:
Finally, a message is printed to the console to confirm that the filtered
data has been saved successfully.

This program effectively combines, filters, sorts, and writes the data from
multiple Excel files into a single text file, organized by different criteria.

You might also like