Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,11 +28,15 @@ def analyze_file(uploaded_file):
|
|
| 28 |
|
| 29 |
# Check if required columns are present
|
| 30 |
if 'Gain (dB)' in df.columns and 'Frequency (GHz)' in df.columns:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
# Convert pandas columns to numpy arrays before performing operations
|
| 32 |
gain_values = np.array(df['Gain (dB)'])
|
| 33 |
freq_values = np.array(df['Frequency (GHz)'])
|
| 34 |
|
| 35 |
-
# Handle infinite
|
| 36 |
gain_values[np.isinf(gain_values)] = np.nan
|
| 37 |
freq_values[np.isinf(freq_values)] = np.nan
|
| 38 |
|
|
|
|
| 28 |
|
| 29 |
# Check if required columns are present
|
| 30 |
if 'Gain (dB)' in df.columns and 'Frequency (GHz)' in df.columns:
|
| 31 |
+
# Handle NaN values by replacing them with the mean of the column
|
| 32 |
+
df['Gain (dB)'].fillna(df['Gain (dB)'].mean(), inplace=True) # Replace NaN with the mean of the column
|
| 33 |
+
df['Frequency (GHz)'].fillna(df['Frequency (GHz)'].mean(), inplace=True) # Replace NaN with the mean of the column
|
| 34 |
+
|
| 35 |
# Convert pandas columns to numpy arrays before performing operations
|
| 36 |
gain_values = np.array(df['Gain (dB)'])
|
| 37 |
freq_values = np.array(df['Frequency (GHz)'])
|
| 38 |
|
| 39 |
+
# Handle infinite values by replacing them with NaN and then replacing NaNs with 0
|
| 40 |
gain_values[np.isinf(gain_values)] = np.nan
|
| 41 |
freq_values[np.isinf(freq_values)] = np.nan
|
| 42 |
|