I have a data frame I've created by using pandas to extract data from a google docs page. The google doc contained a 332x3 table. The middle column contained a set of characters, and the columns on either side contained sets of corresponding values for x and y coordinates on a plane. The idea is that the characters can be arranged in the place of the corresponding coordinates to create an image. I've successfully extracted the data using pandas and converted it into a data frame. I then formatted that data-frame so that all the data was stored in ascending order of the coordinates (ordered from the character stored at the smallest coordinates to that of the largest coordinates). I want to print the data in such a format that I can view the final image. I thought the best way would be to make a 2D array and store the image data at the corresponding values using nested for loops. But they keep running out of bounds. I decided to make a 2D array, corresponding in size with the maximum X and Y values of the stored coordinates. Then using a nested loop, storing each character from the data frame, into the array at the corresponding coordinates. I used the .iloc method to iterate through each row of the df and store the corresponding character into it's appropriate coordinate. This gave me the following errors: IndexError: indices are out-of-bounds IndexError: positional indexers are out-of-bounds I thought I could resolve this by using an if statement inside the nested loop to only store a value if the loop remained inside the bounds of the max value of items in the data frame but that didn't work. Here is the code I'm working with, can someone help me resolve this error. #converts List into Data-frame of int cords and characters df = df_list[0] df = pandas.DataFrame(df) df.drop([0], inplace = True) df[0] = df[0].astype(int) df[2] = df[2].astype(int) #create a list of just the characters without the corresponding cords allImageData = df_list[0][1] allImageData = allImageData[1:] #get grid values numOfItems = len(df_list[0]) xCordValue = max(df[0]) yCordValue = max(df[2]) #order Data-frame by ascending order of coordinates df.sort_values([0,2], ascending=[True, True], inplace=True) #print("\n sorted DF") #print(df.head(100)) grid = {} i = 0 for x in range(xCordValue): for y in range(yCordValue): #grid[x,y] = '.' if(i <= numOfItems): grid[x,y] = allImageData.iloc[] i = i+1 print(grid) for y in range(yCordValue): print(' '.join(grid[x, y] for x in range(xCordValue)) The sorted data-frame, when printed looks like this X-coordinates character y-coordinates 0 █ 0 0 █ 1 ... ... 24 █ 6 25 █ 0 Continue reading...