Skip to content

Tag: python

code completion support with gi.repository in VS Code

I’m trying do code a simple app with GTK4 in Python using VS Code. What I do: I don’t have any auto completion or type hints in my IDE because gi.repository uses dynamic imports, is there any way to change this behavior? Answer In Python typing annotations can be written separately from the main m…

Strip positional information from subprocess std out

I am running a subprocess in python, capturing the std output: The command in question uses positional characters to update the number of packets sent, but in the resultant output, eg results.stdout, I see all of the updates. Ideally, I only want to save the final output, eg Not every one of the 194 interim l…

Transform dataframe format

How do I convert the following dataframe from df1 to df2? Thanks in advance! Answer You could try as follows. Apply .str.split to columns a and b in a loop, each time exploding the result. This will get us 2 pd.Series and we use pd.concat to put them together. After this, we just need to assign col c, and res…

Set_column breaks on date formats in xlsxwriter for python

I am a new python user and I am trying to understand why set_column and conditional_format work differently when I feel they should work the same. Here is an example of my code for set column. What I am doing here is trying to apply a date color for col6 and col 7 ‘startDate’ and ‘endDate&#8…