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(inc lude=['flo at64']).va lues[:,0] )
2. What does [0,24,51] represent :
print(Excluding Specific Row indices::" )
print(df.drop([0,24,51], axis=0).head())
print(Using Column Data Type::" )
print(df.select_dtypes(inc
2. What does [0,24,51] represent :
print(Excluding Specific Row indices::" )
print(df.drop([0,24,51], axis=0).head())
2. What does [0,24,51] represent ?
For pandas dataframe df.drop([0,24,51], suppress lines 0,24,51
example
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
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
https://numpy.org/doc/1.18/user/basics.indexing.html?highlight=slice
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Values representing a numpy array with values of pandas data frame.
[:,0] is the first column of the numpy Array.