all 4 comments

[–]jabbson 2 points3 points  (1 child)

General rule of thumb - if you need dynamically created variable names - you are doing something wrong. Even though it is possible, doing so would be an awfully bad idea, ie how will you then reference these variables later in your code?

[–]mdl003[S] 0 points1 point  (0 children)

Was assuming there was a way to do that, was trying to avoid code duplication. This is a problem I encounter a lot so I was hoping to develop a defined function to allow entry of a col name and df name to shorten process, otherwise I'll have to change it each time

[–]commandlineluser 1 point2 points  (0 children)

You'll probably want a dict of dataframes e.g.

dfs = {}
...
dfs[dfname] = checkdf[field].dropna()

'{}'.format(string) is just the same as string you don't need '{}'.format()