Permutedims not working on DataFrame

Hi all,
I am trying to transpose a DataFrame, following what is explained here: Functions · DataFrames.jl

When applying the ‘permutedims’ function, I get an error that says that this function cannot take a DataFrame as an input.

julia> typeof(df_all)
DataFrame

julia> df_transpose = permutedims(df_all,1)
ERROR: MethodError: no method matching permutedims(::DataFrame, ::Int64)
Closest candidates are:
  permutedims(::StridedArray{T, N} where {T, N}, ::Any) at multidimensional.jl:1494
  permutedims(::FillArrays.AbstractFill, ::Any) at /home/maf190004/.julia/packages/FillArrays/7oBjc/src/fillalgebra.jl:21
  permutedims(::SparseArrays.AbstractSparseMatrixCSC, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/SparseArrays/src/sparsematrix.jl:1068
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[200]:1

The same code runs fine in my coauthors Julia installation. I have tried to update, remove and reinstall the suspect packages (DataFrames, SharedArrays). Unfortunately I cannot simply uninstall Julia and perform a clean install, as this is happening in a HPC. Has anyone seen this before?

The same code runs fine in my coauthors Julia installation. I have tried to update, remove and reinstall the suspect packages (DataFrames, SharedArrays). Unfortunately I cannot simply uninstall Julia and perform a clean install, as this is happening in a HPC. Has anyone seen this before?

You should be using a Manifest.toml to control the versions of packages used in your project. Are you using the exact same versions of the packages your co-author is using?

Good point - thanks. Still, why would permutedims not work on a DataFrame?

Because it was only implemented in v0.22:

Thank you. This solved my issue. For some reason, DataFrames was only updating to 0.21.8 even after doing Pkg.update(DataFrames). I had to force installation of that version to get 0.22 installed.

Please use Manifest.toml files and proper package management rather than relying on updating the packages. Julia’s package management and compatibility system is really good!

1 Like

I got this error with DataFrames v1.3.6…

The exact error in the OP, a missing method for permutedims(::DataFrame, ::Int)? That seems unlikely, here’s DataFrames 1.3.6:

julia> df = string.(DataFrame(rand(5, 5), :auto));

julia> permutedims(df, 1)
4×6 DataFrame
(...)

or are you trying to call single arg permutedims?

julia> permutedims(df)
ERROR: MethodError: no method matching permutedims(::DataFrame)

for that you need to be on DataFrames 1.4 (latest release is 1.6, so there isn’t really a reason to use 1.3):

julia> permutedims(df)
5×5 DataFrame
(...)