Datafrme as follows:
julia> df3
8×6 DataFrame
│ Row │ RegionID │ RegionName │ StateName │ SizeRank │ 2008-03 │ 2008-04 │
│ │ Any │ Any │ Any │ Any │ Any │ Any │
├─────┼──────────┼──────────────┼──────────────┼──────────┼─────────┼─────────┤
│ 1 │ 6181 │ New York │ New York │ 1 │ missing │ missing │
│ 2 │ 12447 │ Los Angeles │ California │ 2 │ 1446 │ 1705 │
│ 3 │ 39051 │ Houston │ Texas │ 3 │ 2926 │ 3121 │
│ 4 │ 17426 │ Chicago │ Illinois │ 4 │ 2910 │ 3022 │
│ 5 │ 6915 │ San Antonio │ Texas │ 5 │ 1479 │ 1529 │
│ 6 │ 13271 │ Philadelphia │ Pennsylvania │ 6 │ 1609 │ 1795 │
│ 7 │ 40326 │ Phoenix │ Arizona │ 7 │ 1310 │ 1519 │
│ 8 │ 18959 │ Las Vegas │ Nevada │ 8 │ 1618 │ 1856 │
Throws error while selecting the rows where StateName is equal to Arizona, as follows:
julia> filter(:StateName => ==("Arizona"), df3)
ERROR: MethodError: objects of type Pair{Symbol,Base.Fix2{typeof(==),String}} are not callable
Stacktrace:
[1] (::DataFrames.var"#53#54"{Pair{Symbol,Base.Fix2{typeof(==),String}}})(::DataFrameRow{DataFrame,DataFrames.Index}) at ./none:0
[2] iterate at ./generator.jl:47 [inlined]
[3] collect at ./array.jl:665 [inlined]
[4] filter(::Pair{Symbol,Base.Fix2{typeof(==),String}}, ::DataFrame) at /opt/julia/julia-1.4.1/share/julia/stdlib/v1.4/packages/DataFrames/yH0f6/src/abstractdataframe/abstractdataframe.jl:758
[5] top-level scope at REPL[102]:1
Please guide me in selecting the rows where StateName is equal to Arizona.
Please update your DataFrames.jl to the latest version (currently 1.2). You are on pre 1.0 release version. If you have to stick to your version do:
filter(row -> row.StateName == "Arizona", df3)
or just
df3[df3.StateName .== "Arizona", :]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With