Need help understanding simple Array code. Please. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Need help understanding simple Array code. Please. (/thread-17495.html) |
Need help understanding simple Array code. Please. - stluwa - Apr-13-2019 import pandas import numpy dataframe = pandas.read_csv("C:\Users\stluwa\cars.csv") array = dataframe.values X = array[:,0:8] Y = array[:,8]My problem is, I can not seem to figure out what is happening in the lines: X = array[:,0:8] Y = array[:,8]My biggest question is what the [:,0:8] means. I'm doing some feature selection stuff, but i never learned python. RE: Need help understanding simple Array code. Please. - loomski - Apr-13-2019 (Apr-13-2019, 05:38 PM)stluwa Wrote:import pandas import numpy dataframe = pandas.read_csv("C:\Users\stluwa\cars.csv") array = dataframe.values X = array[:,0:8] Y = array[:,8]My problem is, I can not seem to figure out what is happening in the lines: Hey, I'm not sure why it's [:,0:8] or [:,8] but it should instead be [:0:8] and [:8] respectively. These are slices. You can read more about them here. https://docs.python.org/3/tutorial/introduction.html#strings https://docs.python.org/3/tutorial/introduction.html#lists |