0
y = Data_read.loc[:, ((Data_read == 0) | (Data_read == 1) ).all()]
a = pd.isna(Data_read)

for parameter in y:
    aa = {}
    aa[parameter] = aa
    aa = 'binary parameter =' , parameter
    print(aa)
for parameter in a:
   if a[parameter].any() == True or parameter in y:
         bb = 'Invalid Parameter = ', parameter
         print(bb)
   
         
   else:
      cc = 'Valid Parameter = ', parameter
      print(cc)

When I try to print the value for aa I only get one variable in result, how can I save all the variables from loop in aa.

1
  • Remove aa = 'binary parameter =' , parameter and just print it. Commented Aug 16, 2022 at 11:03

1 Answer 1

2

You have two problems in your code.

  1. You are overriding the aa variable on this line:

    aa = 'binary parameter =' , parameter

Initially, you declared aa to be a set, but now you set it to something else. You have to use another variable name.

  1. You redefine the aa variable at the start of each for loop on this line:

    aa = {}

Again it creates the same problem. Every time for loop runs, you start with an empty dictionary. You must move this line out of the for-loop

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.