I have created a function as below to create a dataframe from a bigger dataframe
def prepare_data(cyl,typ):
global variable_name
global variable_name2
mask_bel1800 = (data_train_bel1800['Cycle'] == cyl) & (data_train_bel1800['Type'] == typ)
variable_name = ("DF{c}_{s}".format(c=cyl, s=typ))
variable_name = data_train_bel1800.loc[mask_bel1800, :]
mask = (data_train['Cycle'] == cyl) & (data_train['Type'] == typ)
variable_name2 = ("DF{c}_{s}_full".format(c=cyl, s=typ))
variable_name2 = data_train.loc[mask, :]
print('dataframe ' +'"DF'+str(cyl)+'_'+str(typ) +'"'+ " upto 1800 is ready")
print('dataframe ' +'"DF'+str(cyl)+'_'+str(typ)+'_full'+'"' " is ready")
When I put the statement print(variable_name) inside this function, the dataframe is printed.
However, after i run this function & then I try to access the dataframe with df.head(), i get the error 'df is not defined'!!! what i am doing wrong?
If I 'print' the dataframe directly, it prints (pic below)

I checked to make sure i have the right dataframe name by print just the variable "Variable name" and that is correct also
]3
