I’m using my complex jobs app in production and it works fine, with sqlite database. I’m trying to create new database from scratch and I cannot do that nor using migrations nor trying to make them once again: When I’m trying to reuse my migrations: When I’ve tried to remove all migrat…
Tag: python
Python re-setting the for loop if an element is deleted in an iteration
The above code is an idea to explain the task what Iam performing. I have a list that Iam looping through when it finds something or meet some condition it will delete that specific index element accordingly. For instance if it finds element ‘c’ in the list then it will delete it from the list but…
Python: how to get Windows desktop background color
Context: on my office PC there is apllied corporate policy -> standard company picture on desktop wallpaper. Picture is too bright; I switch it off to more dark backgroubd color, do it by manually running the script several times per day. Aim: automate this operation with Python once per some time check so…
Read run_id in airflow operator for non templated fields
I am trying to read run_id for DAG in SnowflakeOperator to set a session parameter, query_tag. But it seems like the session parameter is not templated. How can I reference run_id and use it as an input here? Answer You need to make the non-templated field templated. Then you can use it as:
Why I can’t get the window title of Edge in python 3
Why can’t i get the window title of Microsoft Edge in Python 3 My coding environment: windows10(x86) python3.7 I want to use win32gui to get the active window title, but I met some problem when I opened Microsoft Edge. Here is my code: As my code said I want to get current active window title after each…
Replicate a function from pandas into pyspark
I am trying to execute the same function on a spark dataframe rather than pandas. Answer A direct translation would require you to do multiple collect for each column calculation. I suggest you do all calculations for columns in the dataframe as a single row and then collect that row. Here’s an example.…
How to assign multiple variables one line that depend on each other in python
So I know that you can assign multiple variables in one line like so: But can you assign a variable based off of the value of another variable in one line? Idea: I know that the idea code doesn’t work but is there some way to replicate this in one line even if longer or weirder? NOTE: Using ; like
Group by the column in df python
I have a simple df. It has two columns. I want to groupby the values based on column a. Here is a simple example: Any input would be greatly appreciated! Desired output is: df Answer Here’s a way to do what you want. First you want to group by column ‘a’. Normally groupby is used to calculat…
I want to find the first, second, and last words in a string
Given a string, I want to write 3 separate functions: first_word is to print the first word of the string second_word is to print the second word of the string last_word is to print the last word of the string If the string has 2 words in total, the output from function 2 should be equal to function 3. Exampl…
How to get a full-page screenshot in Python using Selenium and Screenshot
I’m trying to get a full-length screenshot and haven’t been able to make it work. Here’s the code I’m using: But this gives us a clipped screenshot: So as you can see that’s just what the driver window is showing, not a full-length screenshot. How can I tweak this code to get wha…