If I slice a pandas dataframe
with dataset.iloc[:, 1:2].values
, it's giving me a 2 dimensional(matrix)
structured data where dataset.iloc[:, 1].values
is giving me 1 dimensional
data. So, my doubt is iloc[:,1:2]
& iloc[:,1]
dont do the same thing ?
Here is the sample code:
>>> df1 = df.iloc[:, 1:2].values
>>> print(df1.shape,df1.ndim)
(9578, 1) 2
>>> df2 = df.iloc[:, 1].values
>>> print(df2.shape,df2.ndim)
(9578,) 1
>>>