# Plot the following table Please

**URL:** <https://discourse.julialang.org/t/plot-the-following-table-please/46714>\
**Category:** Visualization\
**Created:** [September 16, 2020, 3:26pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714 "2020-09-16T15:26:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mun\_Barimukh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mun_barimukh/32/17927_2.png) [@Mun\_Barimukh](https://discourse.julialang.org/u/Mun_Barimukh)\
**Post date:** [September 16, 2020, 3:26pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/1 "2020-09-16T15:26:54Z")

</div>

[{“metadata”:{“trusted”:true},“cell\_type”:“code”,“source”:“using DataFrames;df = DataFrame(m)”,“execution\_count”:14,“outputs”:[{“data”:{“text/html”:"

40 rows × 3 columns (omitted printing of 1 columns)

| | shoename | shoeprice |
| --- | --- | --- |
| | String | String |
| 1 | Dwane IDP Running Shoes For Men\xa0\xa0(Black) | 1,599 |
| 2 | Jio-13 Running Shoes For Men\xa0\xa0(Silver, Black) | 474 |
| 3 | DROGO M SS 19 Running Shoes For Men\xa0\xa0(Blue) | 1,699 |
| 4 | IMPULSE Running Shoes For Men\xa0\xa0(Blue) | 1,039 |
| 5 | SM-397 Running Shoes For Men\xa0\xa0(Red, Black) | 840 |
| 6 | LEGEND Walking Shoes For Men\xa0\xa0(Blue) | 1,049 |
| 7 | Marsh Cricket Shoes For Men\xa0\xa0(White, Blue) | 890 |
| 8 | Revolution 3 Running Shoes For Men\xa0\xa0(Grey) | 2,401 |
| 9 | Men SM-406 Black Running Shoes For Men\xa0\xa0(Black) | 882 |
| 10 | WNDR-13 Running Shoes For Men\xa0\xa0(Red, Black) | 474 |
| 11 | Running Shoes For Men\xa0\xa0(Navy) | 474 |
| 12 | HYPERON M SS 19 Walking Shoes For Men\xa0\xa0(Black) | 1,649 |
| 13 | 19 FH Rubber Cricket Shoes For Men\xa0\xa0(Red, Black) | 2,749 |
| 14 | DROGO M SS 19 Running Shoes For Men\xa0\xa0(Blue, Orange) | 1,699 |
| 15 | WNDR-13 Running Shoes For Men\xa0\xa0(Black, Grey) | 474 |
| 16 | SM-406 Running Shoes For Men\xa0\xa0(Navy, Grey) | 882 |
| 17 | Dwane IDP Running Shoes For Men\xa0\xa0(Blue) | 1,599 |
| 18 | Running,Gym,Sports Walking Shoes For Men\xa0\xa0(Black) | 399 |
| 19 | Oxygen Running Shoes For Men\xa0\xa0(White, Navy) | 459 |
| 20 | SM-397 Running Shoes For Men\xa0\xa0(Blue, Black) | 840 |
| 21 | ROYCE Running Shoes For Men\xa0\xa0(Blue) | 888 |
| 22 | VERTIGO BLK RUNNING SHOES For MEN 10 Running Shoes For Men\xa0\xa0(Black) | 999 |
| 23 | Gel-Contend 4B Running Shoes For Men\xa0\xa0(Black) | 1,924 |
| 24 | Dwane IDP Running Shoes For Men\xa0\xa0(White) | 1,599 |
| 25 | SM-300 Running Shoes For Men\xa0\xa0(Navy, Green) | 714 |
| 26 | Jio-13 Running Shoes For Men\xa0\xa0(Green) | 474 |
| 27 | Running Shoes For Men\xa0\xa0(Navy) | 474 |
| 28 | Density Running Shoes For Men\xa0\xa0(Navy) | 429 |
| 29 | Running Shoes For Men\xa0\xa0(Black) | 999 |
| 30 | Athleisure Range Sports Walking Shoes For Men\xa0\xa0(Navy) | 1,197 |
| ⋮ | ⋮ | ⋮ |

“,“text/latex”:”\begin{tabular}{r|ccc}\n\t& shoename & shoeprice & \\\n\t\hline\n\t& String & String & \\\n\t\hline\n\t1 & Dwane IDP Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Black) & 1,599 & \\dots \\\n\t2 & Jio-13 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Silver, Black) & 474 & \\dots \\\n\t3 & DROGO M SS 19 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Blue) & 1,699 & \\dots \\\n\t4 & IMPULSE Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Blue) & 1,039 & \\dots \\\n\t5 & SM-397 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Red, Black) & 840 & \\dots \\\n\t6 & LEGEND Walking Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Blue) & 1,049 & \\dots \\\n\t7 & Marsh Cricket Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(White, Blue) & 890 & \\dots \\\n\t8 & Revolution 3 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Grey) & 2,401 & \\dots \\\n\t9 & Men SM-406 Black Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Black) & 882 & \\dots \\\n\t10 & WNDR-13 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Red, Black) & 474 & \\dots \\\n\t11 & Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Navy) & 474 & \\dots \\\n\t12 & HYPERON M SS 19 Walking Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Black) & 1,649 & \\dots \\\n\t13 & 19 FH Rubber Cricket Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Red, Black) & 2,749 & \\dots \\\n\t14 & DROGO M SS 19 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Blue, Orange) & 1,699 & \\dots \\\n\t15 & WNDR-13 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Black, Grey) & 474 & \\dots \\\n\t16 & SM-406 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Navy, Grey) & 882 & \\dots \\\n\t17 & Dwane IDP Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Blue) & 1,599 & \\dots \\\n\t18 & Running,Gym,Sports Walking Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Black) & 399 & \\dots \\\n\t19 & Oxygen Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(White, Navy) & 459 & \\dots \\\n\t20 & SM-397 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Blue, Black) & 840 & \\dots \\\n\t21 & ROYCE Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Blue) & 888 & \\dots \\\n\t22 & VERTIGO BLK RUNNING SHOES For MEN 10 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Black) & 999 & \\dots \\\n\t23 & Gel-Contend 4B Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Black) & 1,924 & \\dots \\\n\t24 & Dwane IDP Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(White) & 1,599 & \\dots \\\n\t25 & SM-300 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Navy, Green) & 714 & \\dots \\\n\t26 & Jio-13 Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Green) & 474 & \\dots \\\n\t27 & Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Navy) & 474 & \\dots \\\n\t28 & Density Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Navy) & 429 & \\dots \\\n\t29 & Running Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Black) & 999 & \\dots \\\n\t30 & Athleisure Range Sports Walking Shoes For Men\textbackslash{}xa0\textbackslash{}xa0(Navy) & 1,197 & \\dots \\\n\t$\dots$ & \\dots & \\dots & \\\n\end{tabular}\n",“text/plain”:"40×3 DataFrame. Omitted printing of 3 columns\n│ Row │ │ │ ├─────┼\n│ 1 │ │ 2 │ │ 3 │ │ 4 │ │ 5 │ │ 6 │ │ 7 │ │ 8 │ │ 9 │ │ 10 │ \n⋮\n│ 30 │ │ 31 │ │ 32 │ │ 33 │ │ 34 │ │ 35 │ │ 36 │ │ 37 │ │ 38 │ │ 39 │ │ 40 │ "},“execution\_count”:14,“metadata”:{},“output\_type”:“execute\_result”}]}]

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [September 16, 2020, 3:33pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/2 "2020-09-16T15:33:42Z")

</div>

Please provide complete information about what you want to do.

---

<div class="post-metadata">

**Author:** ![Mun\_Barimukh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mun_barimukh/32/17927_2.png) [@Mun\_Barimukh](https://discourse.julialang.org/u/Mun_Barimukh)\
**Post date:** [September 16, 2020, 3:44pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/3 "2020-09-16T15:44:19Z")

</div>

I have got a CSV table in Julia. One of the column as ‘shoeprice’ is  
shown as string. Because of this I am not able to plot it. I need  
your help. I sent you the table already.

---

<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:** [September 16, 2020, 3:55pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/4 "2020-09-16T15:55:03Z")

</div>

Here is an example to help you

```julia
julia> using DataFrames, Plots;

julia> df = DataFrame(shoetype = ["Sneaker", "Boot", "High-heels"], price = [10, 20, 15]);

julia> bar(df.shoetype, df.price);

```

It produces the following graph:

![Screenshot from 2020-09-16 11-54-36](https://global.discourse-cdn.com/julialang/original/3X/b/0/b08cb9e95d04b6e9c894997e68c5b777b2936498.png)

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [September 16, 2020, 5:47pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/5 "2020-09-16T17:47:36Z")

</div>

You can convert strings to numbers with the `parse` function like `parse.(Int, shoeprice)` where `shoeprice` is the shoeprice column in your table.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [September 16, 2020, 7:18pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/6 "2020-09-16T19:18:14Z")

</div>

I had not understood the problem that the numbers were written as strings.  
But a straight parse won’t help, since they contain commas:

```julia
julia> parse(Int, "2,314")
ERROR: ArgumentError: invalid base 10 digit ',' in "2,314"

```

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [September 16, 2020, 7:44pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/7 "2020-09-16T19:44:35Z")

</div>

I have some hacky (not the worlds most performant) string parsing functions to strip out junk if that’d help, but for just stripping commas and spaces it’s easy though…

```nohighlight
comma_strip(x::String) = parse(Int, filter(s -> (s != ',') && !isspace(s), x) )
comma_strip("2,3 0 9,")

```

Not sure what the OP wants though? I am confident they can learn to use Plots.jl

---

<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:** [September 16, 2020, 8:36pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/8 "2020-09-16T20:36:58Z")

</div>

Just looking at the table it seems `parse.(Int, replace.(df.shoeprice, "," => ""))` would do the trick?

---

<div class="post-metadata">

**Author:** ![Mun\_Barimukh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mun_barimukh/32/17927_2.png) [@Mun\_Barimukh](https://discourse.julialang.org/u/Mun_Barimukh)\
**Post date:** [September 17, 2020, 1:06pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/9 "2020-09-17T13:06:47Z")

</div>

Thanks for the suggestion. I need one more help. I have got the table  
applying the following codes. Please help me to get a bar chart from  
it.  
using Pkg;Pkg.add(“StatsPlots”);using DataFrames;df=DataFrame(m)  
df2 = df |\> x → begin x[:shoeprice] =parse.(Int,  
replace.(df.shoeprice, “,” =\> “”)) ; x end

40 rows × 3 columns (omitted printing of 1 columns)

shoename shoeprice  
String Int64  
1 Dwane IDP Running Shoes For Men\xa0\xa0(Black) 1599  
2 Jio-13 Running Shoes For Men\xa0\xa0(Silver, Black) 474  
3 DROGO M SS 19 Running Shoes For Men\xa0\xa0(Blue) 1699  
4 IMPULSE Running Shoes For Men\xa0\xa0(Blue) 1039  
5 SM-397 Running Shoes For Men\xa0\xa0(Red, Black) 840  
6 LEGEND Walking Shoes For Men\xa0\xa0(Blue) 1049  
7 Marsh Cricket Shoes For Men\xa0\xa0(White, Blue) 890  
8 Revolution 3 Running Shoes For Men\xa0\xa0(Grey) 2401  
9 Men SM-406 Black Running Shoes For Men\xa0\xa0(Black) 882  
10 WNDR-13 Running Shoes For Men\xa0\xa0(Red, Black) 474  
11 Running Shoes For Men\xa0\xa0(Navy) 474  
12 HYPERON M SS 19 Walking Shoes For Men\xa0\xa0(Black) 1649  
13 19 FH Rubber Cricket Shoes For Men\xa0\xa0(Red, Black) 2749  
14 DROGO M SS 19 Running Shoes For Men\xa0\xa0(Blue, Orange) 1699  
15 WNDR-13 Running Shoes For Men\xa0\xa0(Black, Grey) 474  
16 SM-406 Running Shoes For Men\xa0\xa0(Navy, Grey) 882  
17 Dwane IDP Running Shoes For Men\xa0\xa0(Blue) 1599  
18 Running,Gym,Sports Walking Shoes For Men\xa0\xa0(Black) 399  
19 Oxygen Running Shoes For Men\xa0\xa0(White, Navy) 459  
20 SM-397 Running Shoes For Men\xa0\xa0(Blue, Black) 840  
21 ROYCE Running Shoes For Men\xa0\xa0(Blue) 888  
22 VERTIGO BLK RUNNING SHOES For MEN 10 Running Shoes For Men\xa0\xa0(Black) 999  
23 Gel-Contend 4B Running Shoes For Men\xa0\xa0(Black) 1924  
24 Dwane IDP Running Shoes For Men\xa0\xa0(White) 1599  
25 SM-300 Running Shoes For Men\xa0\xa0(Navy, Green) 714  
26 Jio-13 Running Shoes For Men\xa0\xa0(Green) 474  
27 Running Shoes For Men\xa0\xa0(Navy) 474  
28 Density Running Shoes For Men\xa0\xa0(Navy) 429  
29 Running Shoes For Men\xa0\xa0(Black) 999  
30 Athleisure Range Sports Walking Shoes For Men\xa0\xa0(Navy) 1197  
⋮ ⋮

---

<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:** [September 17, 2020, 2:58pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/10 "2020-09-17T14:58:09Z")

</div>

See my post above: [Plot the following table Please - #4 by pdeffebach](https://discourse.julialang.org/t/plot-the-following-table-please/46714/4)

---

<div class="post-metadata">

**Author:** ![Mun\_Barimukh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mun_barimukh/32/17927_2.png) [@Mun\_Barimukh](https://discourse.julialang.org/u/Mun_Barimukh)\
**Post date:** [September 19, 2020, 3:16pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/11 "2020-09-19T15:16:11Z")

</div>

Thank a lot for your suggestion. In my table there are 40 shoename and 40 shoeprice. Is there any other way to get all these instead of writing one by one? Looking forward to your kind suggestion.

---

<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:** [September 19, 2020, 6:49pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/12 "2020-09-19T18:49:01Z")

</div>

I wrote out those shoes as an example. Your data is already in the correct format to make that graph.

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [September 22, 2020, 1:16pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/13 "2020-09-22T13:16:31Z")

</div>

I edited the provided code to work with your variables.

```julia
using Plots
bar(df2.shoename, df2.shoeprice)

```

---

<div class="post-metadata">

**Author:** ![Mun\_Barimukh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mun_barimukh/32/17927_2.png) [@Mun\_Barimukh](https://discourse.julialang.org/u/Mun_Barimukh)\
**Post date:** [September 22, 2020, 2:36pm UTC](https://discourse.julialang.org/t/plot-the-following-table-please/46714/14 "2020-09-22T14:36:00Z")

</div>

Thanks a lot. I will check and let you know.
