# Why is Array rotated and flipped?

**URL:** <https://discourse.julialang.org/t/why-is-array-rotated-and-flipped/14834>\
**Category:** New to Julia\
**Tags:** plotting, dataframes\
**Created:** [September 11, 2018, 9:02pm UTC](https://discourse.julialang.org/t/why-is-array-rotated-and-flipped/14834 "2018-09-11T21:02:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam1](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@sam1](https://discourse.julialang.org/u/sam1)\
**Post date:** [September 11, 2018, 9:02pm UTC](https://discourse.julialang.org/t/why-is-array-rotated-and-flipped/14834/1 "2018-09-11T21:02:11Z")

</div>

Hi I am new to Julia, I mostly use Python, so if someone could tell me what I did wrong that would be great.

```julia
using PyPlot
using DataFrames
using CSV

train = CSV.read("mnist_train.csv", datarow=1)
train_labels = train[1]
train = train[2:end]
head(train)

println("Label: ", train_labels[3])
imshow(reshape(convert(Array, train[3, :]), (28,28)), "gray")

```

Julia returns  
 ![JuliaOutput](https://global.discourse-cdn.com/julialang/original/3X/5/e/5e00278ed07508e1434d70c3a86852ed0ce96d45.png)

```julia
%matplotlib inline

import pandas as pd
import matplotlib.pyplot as plt

train = pd.read_csv('mnist_train.csv', header=None)
plt.imshow(train.iloc[2, 1:].values.reshape((28,28)), cmap='gray')
print(f'Label: {train.iloc[2,0]}')

```

Python returns  
 ![PythonOutput](https://global.discourse-cdn.com/julialang/original/3X/f/7/f71b7aed24fc8f63abe13fd5fd69ff0229223f4c.png)

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [September 11, 2018, 9:09pm UTC](https://discourse.julialang.org/t/why-is-array-rotated-and-flipped/14834/2 "2018-09-11T21:09:22Z")

</div>

It looks like your data are stored linearly and you reshape them into a 28x28 matrix. Python performs this operation row-major — that is, it fills each row sequentially. Julia is column major, so it fills each column sequentially. The two are transposes of each other. You can use [`permutedims`](https://docs.julialang.org/en/v1/base/arrays/#Base.permutedims) to convert between the two.

---

<div class="post-metadata">

**Author:** ![sam1](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@sam1](https://discourse.julialang.org/u/sam1)\
**Post date:** [September 11, 2018, 9:54pm UTC](https://discourse.julialang.org/t/why-is-array-rotated-and-flipped/14834/3 "2018-09-11T21:54:12Z")

</div>

Thanks.

I originally tried

```julia
train = DataFrame(transpose(convert(Array, train[2:end])))

```

to access them columnwise but that didn’t work.
