# Permutedims not working on DataFrame

**URL:** https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053
**Category:** General Usage
**Created:** [June 8, 2023, 2:09pm UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053 "2023-06-08T14:09:46Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mfariacastro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mfariacastro/32/4432_2.png) [@mfariacastro](https://discourse.julialang.org/u/mfariacastro)
#### Post date: [June 8, 2023, 2:09pm UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053/1 "2023-06-08T14:09:46Z")

</div>

Hi all,  
I am trying to transpose a DataFrame, following what is explained here: [Functions · DataFrames.jl](https://dataframes.juliadata.org/stable/lib/functions/#Base.permutedims)

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

```julia
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?

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [June 8, 2023, 2:44pm UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053/2 "2023-06-08T14:44:14Z")

</div>

> 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?

---

<div class="post-metadata">

### Author: ![mfariacastro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mfariacastro/32/4432_2.png) [@mfariacastro](https://discourse.julialang.org/u/mfariacastro)
#### Post date: [June 8, 2023, 2:59pm UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053/3 "2023-06-08T14:59:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [June 8, 2023, 3:04pm UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053/4 "2023-06-08T15:04:02Z")

</div>

Because it was only implemented in v0.22:

> **[Release v0.22.0 · JuliaData/DataFrames.jl](https://github.com/JuliaData/DataFrames.jl/releases/tag/v0.22.0)**
>
> DataFrames v0.22.0
> Diff since v0.21.8
> DataFrames v0.22 Release Notes
> Breaking changes
> 
> the rules for transformations passed to select/select!, transform/transform!,
> and combine have been made more ...

---

<div class="post-metadata">

### Author: ![mfariacastro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mfariacastro/32/4432_2.png) [@mfariacastro](https://discourse.julialang.org/u/mfariacastro)
#### Post date: [June 8, 2023, 3:44pm UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053/5 "2023-06-08T15:44:44Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [June 8, 2023, 4:23pm UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053/6 "2023-06-08T16:23:46Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![stesus](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stesus](https://discourse.julialang.org/u/stesus)
#### Post date: [July 20, 2023, 8:36am UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053/7 "2023-07-20T08:36:32Z")

</div>

I got this error with DataFrames v1.3.6…

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [July 20, 2023, 10:22am UTC](https://discourse.julialang.org/t/permutedims-not-working-on-dataframe/100053/8 "2023-07-20T10:22:50Z")

</div>

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

```julia
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
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
julia> permutedims(df)
5×5 DataFrame
(...)

```
