Trying to multiply and make another row in Pandas Dataframe

70
October 20, 2021, at 00:30 AM

How do I make another row called 'Sum'), which contains the sum of for each order line (quantity, multiplied by price). in Pandas. Here is the code:

import pandas as pd
from pathlib import Path
#Make own path to file
files = Path("").rglob("*.csv")
df =[pd.read_csv(file,index_col=0) for file in files ] 
df = pd.concat(df)
df.reset_index(drop=True, inplace=True)
df.dropna(subset = ["Order ID"], inplace=True)
df['Price Each'].astype('int')
df['Quantity Ordered'].astype('int')
#df['Sum']= df['Quantity Ordered'].astype(int) * df['Price Each'].astype(int)
df.assign('Sum'== df['Quantity Ordered'] * df['Price Each'])
print(df)

I get this back: ValueError: invalid literal for int() with base 10: '11.95'

I have tried to use

df['Price Each'].astype('int')
df['Quantity Ordered'].astype('int')
df['Sum']= df['Quantity Ordered'].astype(int) * df['Price Each'].astype(int) 

But I got the same Error as before. Is there a way to to what i intend.

READ ALSO
Append method to add text to body not working [duplicate]

Append method to add text to body not working [duplicate]

This is such a simple command and I am loading jQuery beforehandOther jQuery on the page is working as well

73
Add <a> href to img with appendto

Add <a> href to img with appendto

I'm hoping someone can help

68
How to use database in Heroku

How to use database in Heroku

I am new in web applications and I created first application in djangoI decided to deployment my project in Heroku

24
How to add Admob banner to all the activities in native code using Android Studio?

How to add Admob banner to all the activities in native code using Android Studio?

I started learning mobile development and I am using Android studio to buildI just made my first app, then I added AdMob banner in it

77