Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

df iloc

df.iloc[[0, 2], [1, 3]]
      b     d
0     2     4
2  2000  4000
Comment

pd df iloc

df.iloc[:3]
      a     b     c     d
0     1     2     3     4
1   100   200   300   400
2  1000  2000  3000  4000
Comment

iloc pandas

mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4},
...           {'a': 100, 'b': 200, 'c': 300, 'd': 400},
...           {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }]
>>> df = pd.DataFrame(mydict)
>>> df
      a     b     c     d
0     1     2     3     4
1   100   200   300   400
2  1000  2000  3000  4000

>>>type(df.iloc[0])
<class 'pandas.core.series.Series'>
>>>df.iloc[0]
a    1
b    2
c    3
d    4
Name: 0, dtype: int64
Comment

df iloc

df.iloc[[0]]
   a  b  c  d
0  1  2  3  4
>>> type(df.iloc[[0]])
<class 'pandas.core.frame.DataFrame'>
Comment

return df.iloc[1:]

>>> df.iloc[1:3, 0:3]
      a     b     c
1   100   200   300
2  1000  2000  3000
Comment

pandas df iloc

df.iloc[0, 1]
2
Comment

pandas df iloc

df.iloc[[0, 1]]
     a    b    c    d
0    1    2    3    4
1  100  200  300  400
Comment

PREVIOUS NEXT
Code Example
Python :: python save images from directory to list 
Python :: python while variable is not 
Python :: python add hyphen to string 
Python :: fill column based on values of another column 
Python :: how to extract values from a dictionary 
Python :: generate a list with random length and with random numbers python 
Python :: how does tkinter iconify() function work in python 
Python :: multiple logger instances populating single log python 
Python :: rotate linked list 
Python :: accuracy for each class 
Python :: graph implementation in python 
Python :: join list of string into a single string with comma 
Python :: change xlabel python 
Python :: fetch image url discord py 
Python :: python child class call parent method 
Python :: create list of dictionaries from list of list python 
Python :: django insert bulk data 
Python :: python datetime to unix timestamp 
Python :: best way to access nested key in python 
Python :: task.loop discord.py 
Python :: bash escape double quote windows batch 
Python :: python dataframe show row 
Python :: python single vs double quotes 
Python :: replace all occurrences of a value to nan in pandas 
Python :: Write a Python program to remove a key from a dictionary. 
Python :: python dictionary print key value ascending order 
Python :: django strptime 
Python :: python class example 
Python :: all python versions 
Python :: how to create dynamic list in python 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =