Plots the distribution of a numerical feature. Args: df (pd.DataFrame): DataFrame containing the feature. feature (str): Column name of the numerical feature. bins (int): Number of bins for the histogram. Returns: None
(df, feature, bins=30)
| 232 | |
| 233 | |
| 234 | def plot_feature_distribution(df, feature, bins=30): |
| 235 | """ |
| 236 | Plots the distribution of a numerical feature. |
| 237 | |
| 238 | Args: |
| 239 | df (pd.DataFrame): DataFrame containing the feature. |
| 240 | feature (str): Column name of the numerical feature. |
| 241 | bins (int): Number of bins for the histogram. |
| 242 | |
| 243 | Returns: |
| 244 | None |
| 245 | """ |
| 246 | plt.figure(figsize=(8, 6)) |
| 247 | sns.histplot(df[feature], bins=bins, kde=True, color="blue") |
| 248 | plt.xlabel(feature) |
| 249 | plt.ylabel("Frequency") |
| 250 | plt.title(f"Distribution of {feature}") |
| 251 | plt.grid(alpha=0.5) |
| 252 | plt.show() |
| 253 | |
| 254 | |
| 255 | def plot_boxplots_for_numerical_features(df, numerical_features): |
nothing calls this directly
no outgoing calls
no test coverage detected