Link to home
Start Free TrialLog in
Avatar of Simon Leung
Simon Leung

asked on

Python code query

1. What does .values[:,0] represent in the following code :

print(Using Column Data Type::" )
print(df.select_dtypes(include=['float64']).values[:,0] )

2. What does [0,24,51] represent :

print(Excluding Specific Row indices::" )
print(df.drop([0,24,51], axis=0).head())
Avatar of Louis LIETAER
Louis LIETAER
Flag of France image

1. What does .values[:,0] represent in the following code :

Values representing a numpy array with values of pandas data frame.

[:,0] is the first column of the numpy Array.
2. What does [0,24,51] represent ?

For pandas dataframe df.drop([0,24,51], suppress lines 0,24,51

example
>>> df.drop([0, 1])
   A  B   C   D
2  8  9  10  11

Open in new window

Avatar of pepr
pepr

It does not come from plain Python. Python knows slicing; however, that one is related to NumPy where slicing can be more complex. I am not good at NumPy, so take the following as starting point

https://numpy.org/doc/1.18/user/basics.indexing.html?highlight=slice
ASKER CERTIFIED SOLUTION
Avatar of Louis LIETAER
Louis LIETAER
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial