using DataFrames, CSV
# Used your sample data
df = DataFrame(CSV.File("data.tsv"))
# Filter the columns by country name
france_cols = findall(x -> occursin("France", x), names(df))
# Subset the df
dg = select(df, france_cols)
# Optional : use "sampleX" as col names instead of the country name
rename!(dg, collect(dg[1, :]))
dg = dg[2:end, :]
display(dg)
println(size(dg))
toby默认情况下,DataFrames将数字添加到类似的列名称中:法国,France_1等,因此我选择了所有包含“法国”的列。