user9580899
user9580899

Reputation: 187

Pandas column indexing differ in iloc

what is the difference between the two below code

my_data.iloc[:,2:3]

&

my_data.iloc[:,2]

why the result differ eventhough it seems same?

Upvotes: 1

Views: 42

Answers (1)

BENY
BENY

Reputation: 323236

One output DataFrame another one is return Series

type(df.iloc[2:3])
<class 'pandas.core.frame.DataFrame'>
type(df.iloc[2])
<class 'pandas.core.series.Series'>

Upvotes: 2

Related Questions