TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Pandas DataFrame.iloc[]

Pandas DataFrame.iloc[] with What is Python Pandas, Reading Multiple Files, Null values, Multiple index, Application, Application Basics, Resampling, Plotting the data, Moving windows functions, Series, Read the file, Data operations, Filter Data etc.

<< Back to PANDAS

Pandas DataFrame.iloc[]

The DataFrame.iloc[] is used when the index label of the DataFrame is other than numeric series of 0,1,2,....,n or in the case when the user does not know the index label.

We can extract the rows by using an imaginary index position which is not visible in the DataFrame. It is an integer- based position(from 0 to length-1 of the axis), but may also be used with the boolean array.

The allowed inputs for .loc[] are:

  • Integer value, e.g. 7.
  • List or array of integers, e.g [2, 5, 6].
  • Slice object with ints, e.g., 1:9.
  • boolean array.
  • A callable function with one argument that can be the calling Series or the DataFrame. It returns valid outputs for indexing.

It can raise the IndexError if we request the index is out-of-bounds, except slice indexers, which allow the out-of-bounds indexing.

Syntax:

pandas.DataFrame.iloc[]

Parameters:

None

Returns:

It returns the DataFrame or the Series.

Example:

import pandas as pd
a = [{'p': 2, 'q': 4, 'r': 6, 's': 8},
{'a': 200, 'b': 400, 'c': 600, 'd': 800},
{'p': 2000, 'q': 4000, 'r': 6000, 's': 8000 }]
info = pd.DataFrame(mydict)
type(info.iloc[0])
<class 'pandas.core.series.Series'>
info.iloc[0]

Output:

a1
b2
c       3
d4
Name: 0, dtype: int64

Next TopicDataFrame.isin()




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf