iteration

How to make my number board start at 1 end at 9 and arrange itself in 3 rows

How to make my number board start at 1 end at 9 and arrange itself in 3 rows Question: I’m trying to understand this code from "12 Beginner Python Projects – Coding Course" on the FreeCodeCamp Youtube channel and I really don’t understand this code to print a board for the Tic Tac Toe project. …

Total answers: 1

JSON iteration with different format Python

JSON iteration with different format Python Question: I have a JSON feed i need to collect data from but I am running into some issues with iterating and parsing the API data. The function below collects what I need but some horses get scratched (dont race) and the format of their JSON is different to …

Total answers: 1

How to modify a Series(DataFrame) of Pandas in place during iterating?

How to modify a Series(DataFrame) of Pandas in place during iterating? Question: I need to revice values in a Series(column) of Pandas according to another function. During iterating, after I get the result, I don’t want to lookup the series twice, becasue I guess that it wastes time and is not required. For example: import …

Total answers: 1

Iterating through all values of df to replace zero values

Iterating through all values of df to replace zero values Question: I want to iterate through all values of a df so that if it detects some zero, I can replace that specific element with the mean of the adjacent columns. I tried this code but I dont know why isnt working. Somebody can help …

Total answers: 2

Divide every row that shares an identifier in pandas

Divide every row that shares an identifier in pandas Question: id item val o a tire 5 1 a brick 5 2 b wheel 9 3 b brick 6 4 c ice 6 5 c brick 3 6 d brick 3 7 d grass 6 Let’s say I have this dataframe. I want to divide …

Total answers: 2

Iterating through python dictionary giving unexpected behavior

Iterating through python dictionary giving unexpected behavior Question: I need to iterate through a dictionary, assigning key values from user input based on a list. If the user enters anything other than valid values from the list, an else statement or exception catches it, and re-sets the list. I then need to take the values …

Total answers: 1

How I can store in keys and values in a dictionary when iterating?

How I can store in keys and values in a dictionary when iterating? Question: I have a list like this: my_list = [‘@F1’, ‘OBCD’, ‘!’, ‘@F2’, ‘ADDAB’, ‘!’, ‘@F3’, ‘OKKA’, ‘!’] I want it to become a dictionary like this: {‘@F1’: ‘OBCD’, ‘@F2’: ‘ADDAB’, ‘@F3’: ‘OKKA’} However I’m stuck on this: my_dict = {} for …

Total answers: 4