Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

select 2 cols from dataframe python pandas

# Convert the dictionary into DataFrame 
df = pd.DataFrame(data)
  
# select two columns
df[['Name', 'Qualification']]
Comment

select multiple columns in pandas dataframe

df1 = df[['a', 'b']]
Comment

apply on dataframe access multiple columns

df['col_3'] = df.apply(lambda x: x.col_1 + x.col_2, axis=1)
Comment

pandas select multiple columns

#Example, in a df with about 20 columns
#If you want to select columns 1-3, 7, 8, 12-15
# Use numpy's np.r_ to slice the columns and parse it into pandas iloc[] slicer

df.iloc[:, np.r_[1:3, 7, 8, 12:15]]
#This selects all rows "df.iloc[:," and then these selected columns "np.r_[1:3, 7, 8, 12:15]]"
#Remember to import numpy ;)
Comment

select multi columns pandas

df1 = df[['a', 'b']]
Comment

PREVIOUS NEXT
Code Example
Python :: float to string python 
Python :: matplotlib location legend 
Python :: multiprocessing queue python 
Python :: python summary() 
Python :: pandas dataframe 
Python :: pandas remove outliers for multiple columns 
Python :: python dict append 
Python :: tensor get value 
Python :: roman to integer python 
Python :: day name in python 
Python :: random numbers python 
Python :: Export a Pandas dataframe as a table image 
Python :: convert datetime to date python 
Python :: how to make a latency command in discord py 
Python :: self-xss meaning 
Python :: pygame how to find the full screen mode 
Python :: validate ip address python 
Python :: python file hidden 
Python :: check integer number python 
Python :: python convert string to byte array 
Python :: pandas bin columns 
Python :: drop rows from dataframe based on column value 
Python :: how to play video in colab 
Python :: colab version python 
Python :: logging - multiple log file 
Python :: color python 
Python :: how to open pickle file 
Python :: python get parent directory 
Python :: strip first occurence of substring python 
Python :: how to sort a dictionary using pprint module in python 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =