Home > Back-end >  How can I move a matrix down by 1 row and 1 column?
How can I move a matrix down by 1 row and 1 column?

Time:02-01

I was wondering how I can move a matrix in an excel file down one row and one column and then save this new matrix as a new file in the same directory?

Below is the program shown which opens my test excel file:

import pandas as pd
main=pd.read_csv('C:/Users/Jonas/Desktop/testfile/testing.csv') #Reads the matrix in the excel file

The test file contains a 4x3 matrix which somehow when opening in spyder its shown as a 3x3 matrix? why is this also happening.

Thanks.

CodePudding user response:

This is happening because there is no header row in you CSV file, but Pandas by default expects one. Add headers=None to your read_csv call to fix that:

import pandas as pd
main=pd.read_csv('C:/Users/Jonas/Desktop/testfile/testing.csv', headers=None) #Reads the matrix in the excel file
  •  Tags:  
  • Related