count

Alternate method of getting 'There is no solution' to print

Alternate method of getting 'There is no solution' to print Question: Given integer coefficients of two linear equations with variables x and y, use brute force to find an integer solution for x and y in the range -10 to 10. Is there an other way to get ‘There is no solution.’ to print just …

Total answers: 2

Python function which will count the total number of items in values from a dictionary and return another dictionary with item count

Python function which will count the total number of items in values from a dictionary and return another dictionary with item count Question: data = {‘customer1’: [‘milk’, ‘bread’], ‘customer2’: [‘butter’], ‘customer3’: [‘beer’, ‘diapers’], ‘customer4’: [‘milk’, ‘bread’, ‘butter’], ‘customer5’: [‘bread’]} I want the Python function output to be {‘milk’: 2, ‘bread’: 3, ‘butter’: 2, ‘beer’: 1, …

Total answers: 2

count (how to find all letters, and count them)

count (how to find all letters, and count them) Question: How to make = 2(there are two "the") import re text = "there are a lot of the cats" o = re.findall("the", text) print(o) def text(word): count = 0 for word in text: if "ou" in text: count += 1 return count print(count) print(i) this …

Total answers: 2

How to count the occurrences of single items in a list of lists in descending order?

How to count the occurrences of single items in a list of lists in descending order? Question: x=[[‘apple’, ‘banana’, ‘carrot’], [‘apple’, ‘banana’], [‘banana’, ‘carrot’]] I want the result to look like this: dict = {‘banana’: 3,’apple’: 2, ‘carrot’: 2} Asked By: eliza nyambu || Source Answers: You can "flatten" your x, and then just count, …

Total answers: 2

SQL want efficient query to SELECT columnA, columnB FROM table1 WHERE both columnA, columnB are in columnC FROM table2 WHERE columndD > value

SQL want efficient query to SELECT columnA, columnB FROM table1 WHERE both columnA, columnB are in columnC FROM table2 WHERE columndD > value Question: I’m searching for a more efficient method to accomplish something that I’ve already solved with a few different SQL statements. The problem: I have two tables a transactions table, and an …

Total answers: 1

value counts not working with a column filter in Pandas

value counts not working with a column filter in Pandas Question: everyone I was trying to count the number of Yes answered in a column depending on the answer from another previous column to generate pie charts so I’m having problems with this because is giving me counts in boolean like in image below, (This …

Total answers: 2

If conditional from df to write predeterminated text with FPDF

If conditional from df to write predeterminated text with FPDF Question: I’m using FPDF to generate reports with charts so I was thinking about using conditionals to use predeterminated text depending on the results from the df[‘COLUMN’].value_counts() with something like this: This is a df, with multi-index generated using a for with value.counts() for each …

Total answers: 1