I have an excel file which contains my data. This is it: enter image description here After reading and storing it in 'Data' variable, I wanna divide it into 2 portions and assign each of them to different variables. I mean that I want to extract 2 matrices with inconsistent shapes out of my data input. For example if my data is the picture I've put here, I want these two out of it: enter image description here and enter image description here I used this indexing but it didn't work. This is the code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
FilePath='E:\\# Civil Engineering graduate\\Projects\\Python\\RoutePlanning'
FileName='\\Data.xlsx'
Data=pd.read_excel(FilePath+FileName)
print(Data)
Points=np.array(Data[1:,0:3])
And this is the error it throughs:
Exception has occurred: TypeError
'(slice(1, None, None), slice(0, 3, None))' is an invalid key
File "E:\# Civil Engineering graduate\Projects\Python\RoutePlanning\RoutePlanning.py", line 9, in <module>
Points=np.array(Data[1:,0:3])
I've seen few solutions that have used loops and function definitions for this purpose which I don't like to follow unless I have to... Definitely I have made a mistake in indexing here since it's not working. But I wanna know that can this be repaired and become operational or is there any indexing like solution for this or not. And if not, what could be the best performing solution.