In Python, if you have a variable numbers = 5
and then in the next like you write numbers = 55
, the variable's value is updated.
While using Pluto.jl, I declared a variable called y_axis
. I decided to change the value of this variable in another cell but I am getting this error:
Multiple definitions for y_axis.
Combine all definitions into a single reactive cell using a `begin ... end` block.
Why doesn't Pluto.jl let me change a variable? Let me show you exactly what I am talking about. This is the 1st cell:
begin
countries_data_labels = ["Italy", "Germany", "Pakistan", "Turkey", "United Kingdom"];
y_axis = DataFrame() # Creating an empty dataframe to populate the y-axis when plotting graphs.
...
end
And this is 2 cells below:
begin
...
y_axis = select!(y_axis, Not([:One_million]));
end
I'm sure Pluto allows changing a variable without having to create a giant block of a cell but I don't know how.
This is covered in the Pluto FAQ:
How can I modify a variable in a different cell?
Variables can only be assigned and modified in a single cell. This is what makes reactivity possible
https://github.com/fonsp/Pluto.jl/wiki/%E2%9A%A1-Writing-and-running-code
If you are used to a different workflow from python, consider using jupyter Notebooks via IJulia.