list

How to change columns values(list) using another data frame in Python

How to change columns values(list) using another data frame in Python Question: I have two data frame, I need to change column values of first data frame that are in list, using second data frame. First Data frame df1 = pd.DataFrame({‘title’:[‘The Godfather’,’Fight Club’,’The Empire’], genre_ids’:[[18, 80],[18],[12, 28, 878]]}) title genre_ids 0 The Godfather [18, 80] …

Total answers: 2

How to solve a system of linear equations in Python with an iterative method?

How to solve a system of linear equations in Python with an iterative method? Question: I have a system of linear equations represented as strings in Python, and I need to find integer values (positive or negative) for each of the variables that satisfy all equations simultaneously without contradictions. The number of variables and equations …

Total answers: 1

How to return a list type in FastAPI response?

How to return a list type in FastAPI response? Question: My objective is return a list of tags as response. I have a Tag schema like this in my FastAPI app: class Tag(BaseModel): nome: str class Config: from_attributes = True class TagList(BaseModel): tags: List[Tag] = [] class Config: from_attributes = True I wanted return the …

Total answers: 1

lists are accounting for nothing as a similarity?

lists are accounting for nothing as a similarity? Question: I’m trying to find matches in 2 parts of a string of numbers, my input, "ref4" is: Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 Card 2: 13 32 20 16 61 | 61 30 68 82 17 …

Total answers: 1

Removing certain end-standing values from list in Python

Removing certain end-standing values from list in Python Question: Is there an elegant Pythonic way to perform something like rstrip() on a list? Imagine, I have different lists: l1 = [‘A’, ‘D’, ‘D’] l2 = [‘A’, ‘D’] l3 = [‘D’, ‘A’, ‘D’, ‘D’] l4 = [‘A’, ‘D’, ‘B’, ‘D’] I need a function that will …

Total answers: 5

Deleting from a list in Python with a [FOR] loop based on [index]

Deleting from a list in Python with a [FOR] loop based on [index] Question: I have a list that I want to remove from the list based on the index of each element, but when it reaches the middle of the list, because the length of the list of elements has decreased, I face the …

Total answers: 6

Python: How to join string elements in list with complex notation

Python: How to join string elements in list with complex notation Question: Edited to show more accurate strings I have a long list with the following grouping structure. I am showing just two groups, but in reality there are 300. The strings can be any random collection of numbers and letters: ["[‘P431’, ‘N7260’, ‘K492’], [‘R109’, …

Total answers: 3

split by comma and ignore if comma in quotes a data from List of Tuples – Python

split by comma and ignore if comma in quotes a data from List of Tuples – Python Question: I have a list of tuples. lt = [(‘051623’, ‘O143’, ‘1.23’, ‘2023-05-16T18:30:00’, ‘1M allen’, ‘millan’), (‘051623’, ‘O207’, ‘1.23’, ‘2023-05-16T18:35:00’, ‘nM Mn, 4nM, 35uM Fe’, ‘wilo’)] Need to convert to csv string by comma separated but while split …

Total answers: 4