Python For RF
Python For RF
Answer:
```python
import pandas as pd
Answer:
```python
def identify_degrading_cells(df, kpi='Throughput',
threshold=0.2):
# Group by Cell ID and Hour, calculate mean KPI
hourly_kpi = df.groupby(['CellID',
'Hour'])[kpi].mean().unstack()
# Usage example:
degrading_cells = identify_degrading_cells(kpi_df, kpi='SINR',
threshold=0.3)
```
### 3. Visualization
Question: How would you visualize the relationship between
RSRP and throughput from NetAct data?
Answer:
```python
import matplotlib.pyplot as plt
import seaborn as sns
def plot_rsrp_vs_throughput(df):
plt.figure(figsize=(10, 6))
sns.scatterplot(data=df, x='RSRP', y='Throughput',
alpha=0.3)
plt.title('RSRP vs Throughput Relationship')
plt.xlabel('RSRP (dBm)')
plt.ylabel('Throughput (Mbps)')
plt.grid(True)
# Usage:
plot_rsrp_vs_throughput(netact_data)
```
Answer:
```python
def clean_netact_data(df):
# Handle missing values
# For KPIs, we might forward fill or interpolate
df.fillna(method='ffill', inplace=True)
df.fillna(method='bfill', inplace=True)
return df
```
### 5. Automation
Question: How would you automate a daily report generation
for top N worst performing cells based on multiple KPIs?
Answer:
```python
def generate_daily_report(df, top_n=10,
output_file='daily_report.html'):
# Calculate composite score based on multiple KPIs
kpis = ['DropRate', 'HandoverSuccess', 'Throughput', 'SINR']
df['Score'] = (df['DropRate'] 0.4 +
(1 - df['HandoverSuccess']) 0.3 +
(1 - df['Throughput']/df['Throughput'].max()) 0.2 +
(1 - df['SINR']/df['SINR'].max()) 0.1)
return worst_cells
```
Answer:
```python
def analyze_throughput_issues(df):
# Create correlation matrix
corr_matrix = df[['Throughput', 'RSRP', 'SINR',
'BLER']].corr()
# Plot relationships
sns.pairplot(df[['Throughput', 'RSRP', 'SINR', 'BLER']])
# Categorize issues
df['IssueType'] = 'Other'
df.loc[(df['SINR'] < 0) & (df['Throughput'] < 5), 'IssueType']
= 'Interference'
df.loc[(df['RSRP'] < -110) & (df['Throughput'] < 5),
'IssueType'] = 'Coverage'
df.loc[(df['BLER'] > 10) & (df['Throughput'] < 5), 'IssueType']
= 'Retransmissions'
Answer:
```python
import geopandas as gpd
from shapely.geometry import Point
def analyze_geo_kpi(df):
# Convert to GeoDataFrame (assuming lat/lon columns
exist)
geometry = [Point(xy) for xy in zip(df['Longitude'],
df['Latitude'])]
geo_df = gpd.GeoDataFrame(df, geometry=geometry)
return cluster_kpi
```
Answer:
```python
from statsmodels.tsa.seasonal import seasonal_decompose
# Plot components
result.plot()
plt.suptitle(f'{kpi} Time Series Decomposition')
plt.tight_layout()
# Return insights
insights = {
'peak_hours':
ts.groupby(ts.index.hour).mean().nlargest(3).index.tolist(),
'weekly_pattern':
ts.groupby(ts.index.dayofweek).mean().to_dict(),
'trend': result.trend.dropna().iloc[-1] -
result.trend.dropna().iloc[0]
}
return insights
```
# Senior RF Engineer (LTE/5G Optimization) - Python Skills
Assessment
Q1: How would you import and clean KPI data from a NetAct
CSV export in Python?
Answer:
```python
import pandas as pd
return
problematic_cells.sort_values(by=list(kpi_thresholds.keys())[
0], ascending=False)
```
def plot_rsrp_vs_throughput(df):
plt.figure(figsize=(10,6))
sns.scatterplot(x='RSRP', y='Throughput', data=df,
alpha=0.5)
plt.title('RSRP vs Throughput Relationship')
plt.xlabel('RSRP (dBm)')
plt.ylabel('Throughput (Mbps)')
plt.grid(True)
plt.show()
analysis_results = {}
# Coverage analysis
poor_coverage = df[df['RSRP'] < thresholds['RSRP']]
analysis_results['poor_coverage_cells'] =
poor_coverage.shape[0]
analysis_results['poor_coverage_list'] =
poor_coverage['CellID'].unique()
# Capacity analysis
congestion = df[df['PRB_Utilization'] > 80] # Assuming PRB
utilization > 80% is congested
analysis_results['congested_cells'] = congestion.shape[0]
analysis_results['congested_cell_list'] =
congestion['CellID'].unique()
# Quality analysis
poor_quality = df[df['SINR'] < thresholds['SINR']]
analysis_results['poor_quality_cells'] =
poor_quality.shape[0]
return analysis_results
```
Q6: How would you implement a trend analysis for KPIs over
time using Python?
Answer:
```python
def analyze_kpi_trends(df, kpi_list,
time_column='Timestamp'):
# Convert timestamp if needed
df[time_column] = pd.to_datetime(df[time_column])
# Set timestamp as index
df.set_index(time_column, inplace=True)
# Plot trends
plt.figure(figsize=(12,8))
for kpi in kpi_list:
weekly_trends[kpi].plot(label=kpi)
return weekly_trends
```
return {
'spike_times': spikes,
'correlation_analysis':
correlated_kpis.sort_values(ascending=False)
}
```
# Generate visualizations
plt.figure(figsize=(10,5))
daily_data['RSRP'].plot(kind='hist', bins=30)
plt.title('RSRP Distribution')
plt.savefig('rsrp_distribution.png')
return report
```