Skip to content

Tag: python

Concatenating into a new field in a Django query

Consider a table called DataTable. It has two fields, A and B. I want to return all rows of this table plus annotate a field called C that is a concatenation of A and B. Here is what I have tried problem here is that C is literally just the string literal “A – B” for every returned row. I

Efficient regex with lists

I have a list of strings coming from os.listdir() that looks like the following: out of those entries, I wanna get the ones that match the “backup_YYYYMMDD” pattern. The regex for that, with named groups, would be I am trying to create a list that contains the date only from the above (aka the .gr…

How to get the path of a function in Python?

I want to obtain the file path of a function in Python. How to do it? For example, Thank you. Answer You can use the getfile() function from the inspect module for this purpose. For example, given the following files: inspect-example.py external_def.py Executing inspect_example.py produces the following outpu…

Error column doesn’t exist on custom module Odoo

I’m working on a custom module and i need to add field to res.partner model. I’ve add some field to this model but since 1 week, when i try to add a new one i got this error : Other field works good but not this one : I really don’t unterstand why i have this issue. I’ve try to

Pycharm Can’t install TensorFlow

I cannot install tensorflow in pycharm on windows 10, though I have tried many different things: went to settings > project interpreter and tried clicking the green plus button to install it, gave me the error: non-zero exit code (1) and told me to try installing via pip in the command line, which was succ…

Pyspark: how to duplicate a row n time in dataframe?

I’ve got a dataframe like this and I want to duplicate the row n times if the column n is bigger than one: And transform like this: I think I should use explode, but I don’t understand how it works… Thanks Answer The explode function returns a new row for each element in the given array or m…