julia:相当于pythons选择多索引级别(尤其是列)

问题描述 投票:0回答:1

像这样的东西?

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))
python dataframe julia multi-index
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.