Jeremy S
Jeremy S

Reputation: 141

DataFrames, df."example vector in the data()" raises a MethodError

So I have a dataframe df . CSV.read(...) and I have a column labeled 'Population in thousands (2017)' and I used a command

df."Population in thousands (2017)"

This used to be what was working... but I installed some packages and created something and now I get THIS error when I input

df."Population in thousands (2017)"

    ERROR: MethodError: no method matching getproperty(::DataFrame, ::String)
Closest candidates are:
  getproperty(::AbstractDataFrame, ::Symbol) at C:\Users\jerem\.julia\packages\DataFrames\S3ZFo\src\abstractdataframe\abstractdataframe.jl:295
  getproperty(::Any, ::Symbol) at Base.jl:33
Stacktrace:
 [1] top-level scope
   @ REPL[10]:1

Thank you in advance.

Upvotes: 2

Views: 51

Answers (1)

Nils Gudat
Nils Gudat

Reputation: 13800

I can confirm that this works on the current (at the time of writing) DataFrames release:

(jl_yo71eu) pkg> st
      Status `...\AppData\Local\Temp\jl_yo71eu\Project.toml`
  [a93c6f00] DataFrames v1.2.2

julia> using DataFrames

julia> df = DataFrame("Population in thousands (2017)" => rand(5));

julia> df."Population in thousands (2017)"
5-element Vector{Float64}:
 0.8976467991472025
 0.32646068570785514
 0.5168819082429569
 0.8488198612708232
 0.27250141317576815

I'm assuming you're on an outdated version of DataFrames?

Edited to add following discussion in comments:

Bogumil can of course read your DataFrames version of the random folder name, so it appears you really are on an outdated version. You should do add [email protected] in the package manager to force an upgrade, which will tell you what packages in your current environment are holding you back.

Upvotes: 3

Related Questions