Skip to content

How do I fix a ‘ list index out of range’ error?

I’m a beginner programmer currently learning Python and I’m programming a game for the first time. The name and result of the winner is written to an external file and can be read from and displayed in the form of a table. However, I am getting an error here: This is the whole function for referen…

Splitting columns and reformat date using pandas

I have an object, slist that I need to split, reformat the date, and export as a tab delimited file. For the splitting I think I’m tripping up understanding the first row? Here is slist: I’ve tried the following: Which gives me something like this: I’ve spent a ton of time trying to figure t…

How to select keys from a dictionary by their order?

Sorry this is probably very simple, but I suspect I’m wording the question wrong from inexperience so I haven’t been able to find the answer anywhere. I have a dictionary, e.g.: dict = {1: ‘a’, 2: ‘b’} I want to select specific values within the dictionary from knowing only…

combine multiple lines into one column

Here is my dataframe following the merging of two separate dataframes. In the [order] column, orders 2, 4 and 5, have multiple corresponding amounts in the [value] column. This is replicated elsewhere in the dataframe at random points. What can I do to merge these amounts so that I am left with one row in the…