Câu 1:

Dùng R để Tính trung bình, phương sai và độ lệch chuẩn của Sepal.Width cho tất cả dòng dữ liệu
Vẽ biểu đồ scatter giữa Petal.Length và Petal.Width, phân loại theo Species bằng ggplot2

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
# Load dữ liệu iris (có sẵn trong R)
data <- iris
# Caculate mean, variance, standard deviation
mean_sepal_width <- mean(iris$Sepal.Width)
var_sepal_width  <- var(iris$Sepal.Width)
sd_sepal_width   <- sd(iris$Sepal.Width)

print(c("Mean of sepal width: ", mean_sepal_width))
## [1] "Mean of sepal width: " "3.05733333333333"
print(c("Variance of sepal width: ", var_sepal_width))
## [1] "Variance of sepal width: " "0.189979418344519"
print(c("Standard deviation of sepal width: ",sd_sepal_width))
## [1] "Standard deviation of sepal width: " "0.435866284936698"
ggplot(iris, aes(x = Petal.Length, y = Petal.Width, color = Species)) +
  geom_point(size = 2.5) +
  labs(
    title = "Scatter plot giữa Petal.Length và Petal.Width",
    x = "Petal Length",
    y = "Petal Width"
  ) + 
theme_minimal()

library(reticulate)
py_require("pandas")

Câu 2:

Đọc file iris.csv Tính tổng giá trị của Sepal.Length và Sepal.Width theo từng loại Species Xuất kết quả ra file total_by_species.csv

import pandas as pd
data = pd.read_csv("iris.csv")

total_result = data.groupby("species")[["sepal.length", "sepal.width"]].sum()
# Xuất ra file total_by_species.csv
total_result.to_csv("total_by_species.csv")

print(total_result)
##             sepal.length  sepal.width
## species                              
## Setosa             250.3        171.4
## Versicolor         296.8        138.5
## Virginica          329.4        148.7