C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
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:
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()
|