Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python calculated row in dataframe subtract

# Dataframe:
# Class     math score   reading score   writing score           
# Class 1      65                73           74
# Class 2      69                66           64

df.loc['Difference'] = df.apply(lambda x: x["Class 1"] - x["Class 2"])

# Result:
# Class       math score    reading score   writing score         
# Class 1         65               73            74
# Class 2         69               66            64
# Difference      -3                7            10
Comment

PREVIOUS NEXT
Code Example
Python :: hex string to hex number 
Python :: telegram.ext module python 
Python :: python linux command 
Python :: import pycocotools._mask as _mask error Expected 80, got 88 
Python :: how to change padding of dbc.col 
Python :: how to make reportlab table header bold in python 
Python :: python open aspx file 
Python :: how to show rosbag file python 
Python :: developpement limité sinus python 
Python :: Mac: Access your iCloud Documents folder with Jupyter Notebook or JupyterLab 
Python :: pandas join two dataframes 
Python :: python vs java 
Python :: jupyterthemes jplot 
Python :: how to draw threshold line in bar graph python 
Python :: cv2 and PIL BRG to RGB 
Python :: how to get a list of files in a folder in python with pathlib 
Python :: django get current user in form 
Python :: Python Difference between two timedelta objects 
Python :: blender python get current filename 
Python :: how to get module path in python 
Python :: python get colorscale 
Python :: selenium screenshot python user agent 
Python :: error:pip.subprocessor:command errored out with exit status 1: 
Python :: python list insert 
Python :: write code in python to Open all links on a page in separate browser tabs 
Python :: Python Deleting a Tuple 
Python :: reduce dataframe merge 
Python :: pandas find column with max value for each row 
Python :: streamlit format_func example 
Python :: random number list 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =