Skip to content

Tag: python

collecting CLI usage data with python click

I’m a platform engineer building a python CLI app (using click) that teams in the same company could use to launch data processing jobs on our internally managed cluster. I want to build a functionality to collect usage data i.e., record the commands submitted to the app and store them in a database. So…

Collapsing rows

I have the following table below: I would like to collapse Code_1 and Code_2 columns based on ID and Date. Based on what I have found online, I have tried the below snippet of code but it does not seem to be working. df= df.groupby([‘ID’,’Date’]).agg(”.join) DF: ID Date Count_Cod…

get specific list by value python

I have a list of dictionary looks like this. I want to get the list by the value of ‘select’ key. For example: this one is not working because of some error list indices must be integers or slices, not str Answer New answer: Since the original post is edited, I updated my answer. First, If you cer…

How to use pytest fixture with fixture factory?

In scikit-learn, there is a function parametrize_with_checks() that is used as a pytest fixture factory–it returns a pytest.mark.parametrize fixture, and is called as a decorator with an iterable of estimators, e.g. My issue is that my list of estimators may change (or I may have multiple lists), and ea…

How can I retun a list of absolute paths?

The following code returns a list of file-names in a given directory: How can I make it return absolute file paths with minimal modification and preserve the behavior of the function? Answer The easiest way to do this is with pathlib Make your input directory a Path object, use .iterdir() to get all the files…