0
for N_RECORDS in ['50k','50m','100m','200m','python']:
  eval("res_"+N_RECORDS) = spark.read.load("/tmp/xgb-rts/xgb_results_"+N_RECORDS+"_pos.csv")
  eval("res_"+N_RECORDS+"_neg")=spark.read.load("/tmp/xgb-rts/xgb_results_"+N_RECORDS+"_neg.csv")

I just want to create objects with the names res_50k, res_50m, res_100m, res_50k_neg, etc without doing it manually.

However, I keep getting an error

SyntaxError: can't assign to function call
  File "<command-1997330779535506>", line 2
    eval("res_"+N_RECORDS) = spark.read.load("/tmp/xgb-rts/xgb_results_"+N_RECORDS+"_pos.csv"

How do I work around this?

Kashif
  • 3,063
  • 6
  • 29
  • 45

0 Answers0