Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Searching through a list of dictionaries with a condition.
Post: RE: Searching through a list of dictionaries with ...
My bad, I never properly removed the newline characters as I am using a real dataset (a file), as opposed to a constructed one as in the example I gave. Thanks for your patience and guidance. |
|
Mr_Keystrokes |
General Coding Help |
11 |
5,256 |
Oct-05-2018, 11:03 AM |
|
|
Thread: Searching through a list of dictionaries with a condition.
Post: RE: Searching through a list of dictionaries with ...
a_list=[{"Sample" : "A-15", "Run" : "n47", "quality" : "good" },
{"Sample" : "B-04", "Run" : "n45", "quality" : "good"},
{"Sample" : "C-10", "Run" : "n48", "quality" : "bad"},
{"Sample" : "Z-95", "... |
|
Mr_Keystrokes |
General Coding Help |
11 |
5,256 |
Oct-04-2018, 01:46 PM |
|
|
Thread: Searching through a list of dictionaries with a condition.
Post: RE: Searching through a list of dictionaries with ...
|
Mr_Keystrokes |
General Coding Help |
11 |
5,256 |
Oct-04-2018, 09:03 AM |
|
|
Thread: Searching through a list of dictionaries with a condition.
Post: RE: Searching through a list of dictionaries with ...
Yeah, but the question is, if every dictionary in the list has the same keys-values (structure), can one exclusively access and retrieve the value of the key you're interested in and only that key. |
|
Mr_Keystrokes |
General Coding Help |
11 |
5,256 |
Oct-02-2018, 07:35 AM |
|
|
Thread: Searching through a list of dictionaries with a condition.
Post: RE: Searching through a list of dictionaries with ...
Hey apologies for late reply, I'm not getting email alerts. I'm going to try what you said, although I'd like to point out why I created the second loop. It's because I don't know what the syntax is t... |
|
Mr_Keystrokes |
General Coding Help |
11 |
5,256 |
Oct-01-2018, 07:42 AM |
|
|
Thread: Searching through a list of dictionaries with a condition.
Post: RE: Searching through a list of dictionaries with ...
(Sep-28-2018, 12:07 PM)ichabod801 Wrote: It's not overwriting, you are removing the last iteration before you add a new one. The pop method removes the last item of the list. You keep removing an it... |
|
Mr_Keystrokes |
General Coding Help |
11 |
5,256 |
Sep-28-2018, 03:43 PM |
|
|
Thread: poosible bug
Post: RE: poosible bug
I don't think it's a bug. It's just unique to python3.6.
You could use round:
a="1.1"
b="2.2"
# Here the number of decimal places is the 2nd argument.
x=round(float(a)+float(b), 2)
print(x) |
|
Mr_Keystrokes |
General Coding Help |
3 |
2,812 |
Sep-28-2018, 10:05 AM |
|
|
Thread: Searching through a list of dictionaries with a condition.
Post: Searching through a list of dictionaries with a co...
Hey guys,
I have a huge spreadsheet that I am attempting to search through for some specific data.
On the one hand I have IDs like this:
Y00988-11
G01024-14
Z01933-13
And on the other hand I have ... |
|
Mr_Keystrokes |
General Coding Help |
11 |
5,256 |
Sep-28-2018, 08:06 AM |
|
|
Thread: Removing rows at random based on the value of a specific column
Post: RE: Removing rows at random based on the value of ...
Got it, my mistake was not assigning it to a variable as so:
df=df.drop(df.query('salary == 0').sample(frac=.41).index) |
|
Mr_Keystrokes |
Data Science |
4 |
5,638 |
Aug-24-2018, 11:15 AM |
|
|
Thread: Removing rows at random based on the value of a specific column
Post: RE: Removing rows at random based on the value of ...
Yeah that sounds okay, but I would have really liked to do it as described, I'm sure it could be done in R it's just I want start using pandas more. |
|
Mr_Keystrokes |
Data Science |
4 |
5,638 |
Aug-23-2018, 03:13 PM |
|
|
Thread: Removing rows at random based on the value of a specific column
Post: Removing rows at random based on the value of a sp...
As the title entails, I am trying to remove rows from a pandas dataframe at random based on whether the given row (instance) has a certain value in some given column.
For example, suppose I had the f... |
|
Mr_Keystrokes |
Data Science |
4 |
5,638 |
Aug-23-2018, 02:51 PM |
|
|
Thread: Looping through dictionary and comparing values with elements of a separate list.
Post: RE: Looping through dictionary and comparing value...
Thanks, I like the last solution best. Didn't know about csv reader so that will be useful in the future. And I would never have looked up set(). I have to say it's much simpler than Perl. |
|
Mr_Keystrokes |
General Coding Help |
5 |
3,904 |
Jun-22-2018, 02:49 PM |
|
|
Thread: Looping through dictionary and comparing values with elements of a separate list.
Post: RE: Looping through dictionary and comparing value...
You see this is why I like Python. So many simpler ways of doing things you just have to know them. Now I've got to decipher what you've written. Thanks.
len(set(line[1:-1]) & new_isolate)==2]H... |
|
Mr_Keystrokes |
General Coding Help |
5 |
3,904 |
Jun-22-2018, 01:12 PM |
|
|
Thread: Looping through dictionary and comparing values with elements of a separate list.
Post: Looping through dictionary and comparing values wi...
Apologies for the long question. Basically I am trying to loop through a dictionary I've constructed and check whether a specific element of the hash is in a given list.
Test script:
Hash_Isolates={
... |
|
Mr_Keystrokes |
General Coding Help |
5 |
3,904 |
Jun-22-2018, 12:05 PM |
|
|
Thread: Trying to append List/array based on condition
Post: Trying to append List/array based on condition
I'm having problems appending array based on an if statement.
all_staff = ["Judith", "Harry", "Jonathan", "Reuben"]
new_staff = []
def person_finder(staff):
for x in staff:
if x == "Reu... |
|
Mr_Keystrokes |
General Coding Help |
1 |
2,348 |
Mar-20-2018, 12:18 PM |
|
|
Thread: I have an array, how can I search a seperate file for the contents of my array?
Post: I have an array, how can I search a seperate file ...
I have an array (list), how can I search a separate file for the presence of elements that are in my array?
I wanted to use python to do it instead of bash because python is where it's at these days,... |
|
Mr_Keystrokes |
General Coding Help |
0 |
2,346 |
Mar-13-2018, 02:25 PM |
|
|
Thread: What is causing the syntax error?
Post: RE: What is causing the syntax error?
As soon as I type in 'else:' and then press enter to go into the new line it pops up with invalid syntax.
In the following line I would like to write:
print (n, " is an odd number")I am writing this ... |
|
Mr_Keystrokes |
General Coding Help |
5 |
3,865 |
Sep-12-2017, 02:31 PM |
|
|
Thread: What is causing the syntax error?
Post: What is causing the syntax error?
Just started using python a few seconds ago...
n = int(input("Enter a number: "))
if n % 2 == 0:
print (n, " is an even number")
else:
SyntaxError: invalid syntaxThe Else sta... |
|
Mr_Keystrokes |
General Coding Help |
5 |
3,865 |
Sep-12-2017, 01:06 PM |