0

Can anyone explain me whats the Difference between data[0:4] and data.iloc[0:4] when i run these 2 commands iam reciving same output

Here is my code:-

import pandas as pd
data= pd.read_csv("C:/Users/Admin/PycharmProjects/pythonProject1/venv\Lib/site-packages/pandas/test.csv")
print(data[0:4])
print(data.iloc[0:4])

output:- enter image description here

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 1
    There is no difference. The documentation highlights this: https://pandas.pydata.org/docs/user_guide/indexing.html#slicing-ranges – rhug123 Oct 26 '22 at 19:17
  • Welcome to Stack Overflow! Please take the [tour]. [Please don't post pictures of text](https://meta.stackoverflow.com/q/285551/4518341). Instead, copy the text itself, [edit] it into your post, and use the formatting tools like [code formatting](/editing-help#code). For more tips, see [ask]. – wjandrea Oct 26 '22 at 19:24

1 Answers1

1

I really hope this comment helps you understand this concept better https://stackoverflow.com/a/31593712/19275334