Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas dataframe column based on another column

df['c2'] = np.where(df.c1 == 8,'T', 'F')

   c1  c2  c3
0   4   F   1
1   8   T   9
2   1   F   8
3   3   F   5
4   3   F   8
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib show plot 
Python :: remove all rows with at least one zero pandas 
Python :: suppress python vs try/except pass 
Python :: dataframe select data type 
Python :: python find index of first matching element in a list 
Python :: how to add two list by zip function in python 
Python :: word guessing game python 
Python :: tkinter disable button styles 
Python :: how to access dataframe row by datetime index 
Python :: python generator 
Python :: python script to copy files to remote server 
Python :: pandas unique values to list 
Python :: django serialize foreign key, django serializer foreign key 
Python :: python how to add up all numbers in a list 
Python :: euclidean distance python 3 variables 
Python :: procfile for django heroku 
Python :: extends template django 
Python :: create or append dataframe to csv python 
Python :: remove dot from number python 
Python :: pyqt5 image center 
Python :: python check if dataframe series contains string 
Python :: sort first element reverse sort second python 
Python :: filter django or 
Python :: randomly shuffle array python 
Python :: change django administration text 
Python :: read a file python 
Python :: seir model python 
Python :: np array to list 
Python :: Iterate through characters of a string in python 
Python :: zip python 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =