2021年1月23日星期六

How to call a variable that has not been created yet, but it will be, after running the code

I have just created a code where I can get monthly DataFrames for many years just by inserting an input value and it works, but I would like to know how can I call those created variables of DataFrame to make others calculations. Or maybe if there is another way to do that, I would apreciate you could tell me that. Thanks in advance.

My data was stored in a DataFrame named data and there is a column named month

   calculus = int(input("Which data do you want?: \n(1) month\n(2) anual\n"))       # monthly data     if calculus == 1:         month = int(input(" Which month do you want? (1-12): "))         globals()["month_" + str(month)] = data.loc[data['month'] == month]  
https://stackoverflow.com/questions/65867024/how-to-call-a-variable-that-has-not-been-created-yet-but-it-will-be-after-runn January 24, 2021 at 12:03PM

没有评论:

发表评论