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 :: plotly create plot 
Python :: insert a new row to numpy array in especific position 
Python :: pygame get surface region 
Python :: import statsmodels as sm 
Python :: jacobi iteration method python 
Python :: how to calculate the google map distance in python 
Python :: case python 
Python :: python using list as dictionary key 
Python :: python replace in string 
Python :: install tabula 
Python :: how to find out the max and min date on the basis of property id in pandas 
Python :: ascii values in python of 
Python :: python normalized correlation 
Python :: python largest common divisor 
Python :: flask arguments in url 
Python :: how to import something in python 
Python :: django get all model fields 
Python :: how to move the element of an array in python by one step 
Python :: how to backspace in python 
Python :: df to dict 
Python :: difference between 2 dataframes 
Python :: set comprehension 
Python :: fillna string 
Python :: fraction to float 
Python :: Python remove duplicate lines from a text file 
Python :: python in kali linux 
Python :: intialize 2d aray in python 
Python :: python find minimum date in list 
Python :: duplicate a list with for loop in python 
Python :: python use variable name as string 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =