Skip to content

Tag: python

Assign outcome from SQL query to column

I have a dataframe (test_df) that looks like this: I want to assign the result from executing the query in dq_sql to the column Results. I tried this: which results in: Strange thing is, the ‘X’ result should be assigned to row 1, whereas the query in row 0 does not seem to run. When I try to run …

Python: convert dictionary into a cvs file

This is my current code: What I am trying to achieve is that the dictionary keys are turned into the csv headers and the values turned into the rows. But when running the code I get a TypeError: ‘string indices must be integers’ in line 21. Answer Problem The issue here is for row in data. This is…

an alternative to (any) function

I’m currently working on a password validity code, but I didn’t learn the (any) function yet so I should not use it I’m looking for a different way to make the code work and check if there is lowercase, uppercase, and digits in the password. I thought about using a loop that checks each char…

Divide a list by elements of another list

I want to divide a list error_variance_vector by an element in another list sigma_square1, such that it gives corresponding W element (w_i). Here’s my attempt: but I got an error message: Answer This should work: