import pandas as pd
from sklearn.datasets import load_iris

iris = load_iris(as_frame=True)
df = iris.frame

df.columns = ["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species"]

mean_values = df.drop(columns=["Species"]).mean()
mean_values.to_csv("mean_values.csv")

petal_width_mean = df["Petal.Width"].mean()
filtered_df = df[df["Petal.Width"] < petal_width_mean]
filtered_df.to_csv("filtered_petal_width.csv", index=False)
data(iris)
library(ggplot2)


result <- aggregate(
  Petal.Length ~ Species,
  data = iris,
  FUN = function(x) c(
    mean = mean(x),
    sd = sd(x),
    max = max(x)
  )
)


result_df <- do.call(data.frame, result)
print(result_df)
##      Species Petal.Length.mean Petal.Length.sd Petal.Length.max
## 1     setosa             1.462       0.1736640              1.9
## 2 versicolor             4.260       0.4699110              5.1
## 3  virginica             5.552       0.5518947              6.9
ggplot(iris, aes(x = Species, y = Sepal.Width, fill = Species)) +
  geom_violin(trim = FALSE) +
  labs(
    title = "Violin plot của Sepal.Width theo Species",
    x = "Species",
    y = "Sepal.Width"
  ) +
  theme_minimal()