Assigning strictly integer values

Hi,

I am having trouble with assigning values from a CSV file into a variable. So I have a value of 300 in a cell ([4,2]) in the CSV file, and in the code I created a dataframe (df1) and tried to assign the value of 300 into a variable T as follows:

T = df1[4,2]

but it always gets stored as 300.0 and not an integer. I even tried creating an integer variable like this:

@variable(m, T, Int)
T = df1[4,2]

but the result is the same. I even made sure the cell in Excels an integer cell. I need 300 as an integer because I use it for iterations (i = 1:T).

Please advise, thanks!

round(Int, ...)

1 Like

Thank you!

I wonder if tere’s a way to tell DataFrame to store integer

Oh yeah there is actually, in the you can specify when creating the dataframe, for eg;

df = DataFrame(Column1 = Int[]...)

but I just copied the csv contents including the header into the dataframe so I’m not sure if you can specify integer columns that way. I’m still new so I don’t know if there is a way.