filter

How to perform filter map reduce equivalent in Pyhon?

How to perform filter map reduce equivalent in Pyhon? Question: Let’s assume there are two lists like: list1 = ["num", "categ"] all_names = ["col_num1", "col_num2", "col_num3", "col_categ1", "col_categ2", "col_bol1", "col_bol2", "num_extra_1", "num_extra_2", "categ_extra_1", "categ_extra_2"] I am trying to create a new list by filtering the elements that 1) not contain "extra" and 2) contains the …

Total answers: 3

filter a array in a list that contain a certain value

filter a array in a list that contain a certain value Question: I have list combi_col = [[0,1,2][0,1],[0],[1,2],[0,2],[1,2,3],[2,3],[3,1] I want to filter this list to only show a list that only contain 0 in the array The result should only keep all arrays in the list which contain 0 In addition, the array should not …

Total answers: 6

Django 4 REST framework JSON POST request filter

Django 4 REST framework JSON POST request filter Question: I have this API where I need to filter some data. My user will pass a JSON containing several instances that I need to return to them if there existis or not on my database. But I don’t know how I can make Django 4 make …

Total answers: 1

Remove rows from grouped data frames based on column values

Remove rows from grouped data frames based on column values Question: I would like to remove from each subgroup in a data frame, the rows which satisfy certain conditions. The subgroups are grouped based on the two columns Days & ID, here’s my data frame: df = pd.DataFrame({‘Days’:[5,5,5,5,6,6], ‘ID’:[‘A11′,’A11′,’A11′,’A11′,’B12′,’B12’], ‘Country’:[‘DE’,’DE’,’FR’,’US’,’US’,’US’], ‘Car1’:[‘BMW’,’Volvo’,’Audi’,’BMW’,’Mercedes’,’BMW’], ‘Car2’:[‘Volvo’,’Mercedes’,’BMW’,’Volvo’,’Volvo’,’Volvo’], ‘Car3’:[‘Mercedes’,nan,’Volvo’,nan,nan,nan]}, ) Days …

Total answers: 1

how to filter out data from a print out message

How to filter out data from a print out message Question: I have this one problem, where I print out a message response from a website(JSON response), and the response I get is this. Here is my model with fake data: {"token": "MTAxOTAwNjM4NjEyMzg0OTkwMQ.8hkyLV.n0ir2UA4qFE5pXen9YnPtFzgn4xP8tHmVmmkrl", "user_settings": {"locale": "en-US", "theme": "dark"}, "user_id": "101900638614857883"} And, if I only want …

Total answers: 2

"TypeError: cannot unpack non-iterable int object" with filter function

"TypeError: cannot unpack non-iterable int object" with filter function Question: I have a list and I want to filter the tuples in this list using the filter function, but I’m running into a problem that I can’t solve. My code: liste = [(3,4,5),(6,8,10),(3,10,7)] def ucgen_mi(s): for g in s: a, b, c = g if …

Total answers: 2

How to filter dataframe based on condition that index is between date intervals?

How to filter dataframe based on condition that index is between date intervals? Question: I have 2 dataframes: df_dec_light and df_rally. df_dec_light.head(): log_return month year 1970-12-01 0.003092 12 1970 1970-12-02 0.011481 12 1970 1970-12-03 0.004736 12 1970 1970-12-04 0.006279 12 1970 1970-12-07 0.005351 12 1970 1970-12-08 -0.005239 12 1970 1970-12-09 0.000782 12 1970 1970-12-10 0.004235 …

Total answers: 2

pandas how to filter rows by certain conditions after groupby?

pandas how to filter rows by certain conditions after groupby? Question: I’d like to filter the rows with a difference less than 20 after groupby. Here is my original table A B Value 1 1 0 1 2 10 1 2 20 1 2 25 2 1 0 2 1 15 2 1 100 After …

Total answers: 2

Confirm if duplicated employees are in sequence in pandas dataframe

Confirm if duplicated employees are in sequence in pandas dataframe Question: Imagine I have the following dataframe with repetitive people by firstname and lastname: ID FirstName LastName Country 1 Paulo Cortez Brasil 2 Paulo Cortez Brasil 3 Paulo Cortez Espanha 1 Maria Lurdes Espanha 1 Maria Lurdes Espanha 1 John Page USA 2 Felipe Cardoso …

Total answers: 1