I’m trying to calculate the total number of values above 1.6 in my list of 10,000 numbers. I’ve tried a few ways: gives me the error in my title but the following works I want to try two methods to see validate my answer, how can i fix the first one so it works? Answer In the first code snippet,
Tag: list
How to use recursion to give the minimum integer in a list using python?
I am trying to write a recursive function called my_minimum that receives a list of integers as parameter and returns the minimum stored in the list. I am able to get the user to input integers separated by a space. However, it gives me a number totally unrelated to what I am trying to achieve. For example if…
count of unique data in one column of list of lists
I have got list of lists, have to count number of unique values in one of the columns from that list. I have got only to the point to extract that one column from the list by using the following how can I now count unique data in that column? Answer Use set to find unique elements OR
Try to find an element in the list based on a part of the string
I have a list = [‘Assassin Bow’, ‘Bone Bow’, ‘Citadel Bow’] and I have a string = ‘Bone Bow of Fire’ How can I get output ‘Bone Bow’ as the result ? Just started codding, thx for understanding. Answer
remove empty dataframe from list and drop corresponding name in second list
I have two lists, where the first one is a list of strings called names and has been generated by using the name of the corresponding csv files. I have loaded the csv files into individual pandas dataframes and then done some preprocessing which leaves me with a list of lists, where each element is the data o…
How to improve the pattern matching on a list in Python
I have a big list, which may carry thousands to millions of entries. I set a window of finite size to slide over the list. I need to count the matched elements in the windows and repeat the procedure by sliding the window 1 position forward at a time. Here is a simple example of a list Assuming the window
Module object is not callable when using defaultdict package not working in PyCharm [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 1 y…
Why does numpy.where() give two arrays with an array of more than 1 row as input?
I understand the output of np.where() with input of a one-row array. However, when a two-row array was used as an input, I don’t understand why the output of b is two arrays. The output for a[b] makes sense. output for b: output for a[b]: Answer We require two indices to access each element in 2D array.…
Multiple data types in a python list
I have a list for birth data each record has 3 columns for [DOB, weight, height] as such: I need to change the data types of this as they are all strings in the list I want the first item in the record to be datetime and then the rest to be floats. I have: I get an attribute error:
Not finding a good regex pattern to substitute the strings in a correct order(python)
I have a list of column names that are in string format like below: Now I want to add df[] with ” ‘ ” to each column name using regex and I did it which does that when the list has (wallet-phone) this kind of string it gives an output like this df[(‘wallet’]-df[‘phone’…