Как умножить два типа данных объекта в Python? ⇐ Python
Как умножить два типа данных объекта в Python?
This is from Udemy bootcamp course (Day 76).
I am a newbie in Python. So, apologize if I cannot frame my question correctly. I have an excel sheet where there are several columns and the datatypes of each column are as follows. Any help would be greatly appreciated. Thank you. Line 8 is giving me an error in Pycharm.
App object Category object Rating float64 Reviews int64 Size_MBs float64 Installs object Type object Price object Content_Rating object Genres object dtype: object
I want to multiply the "Price" and "Install" columns from excel sheet as shown below and add a new column named 'Revenue Estimate' :
import pandas as pd df=pd.read_csv('apps.csv') clean_df=df.dropna() clean_df.loc[:, "Installs"] = clean_df.loc[:, "Installs"].astype(str).str.replace(",", "") clean_df.loc[:, "Installs"] = pd.to_numeric(clean_df.loc[:, "Installs"]) clean_df.loc[:,"Price"] = clean_df.loc[:,"Price"].astype(str).str.replace('$', "") clean_df.loc[:, "Price"] = pd.to_numeric(clean_df.loc[:,"Price"]) #Line 8: clean_df['Revenue_Estimate']= clean_df.Installs * clean_df.Price Error:
A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/s ... sus-a-copy clean_df['Revenue_Estimate']= clean_df.Installs * clean_df.Price =============
I tried this as well. did not work
df_apps_clean['Revenue_Estimate'] = df_apps_clean.Installs.mul(df_apps_clean.Price) Error:
A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/s ... sus-a-copy clean_df['Revenue_Estimate'] = clean_df.Installs.mul(clean_df.Price)
Источник: https://stackoverflow.com/questions/781 ... -in-python
This is from Udemy bootcamp course (Day 76).
I am a newbie in Python. So, apologize if I cannot frame my question correctly. I have an excel sheet where there are several columns and the datatypes of each column are as follows. Any help would be greatly appreciated. Thank you. Line 8 is giving me an error in Pycharm.
App object Category object Rating float64 Reviews int64 Size_MBs float64 Installs object Type object Price object Content_Rating object Genres object dtype: object
I want to multiply the "Price" and "Install" columns from excel sheet as shown below and add a new column named 'Revenue Estimate' :
import pandas as pd df=pd.read_csv('apps.csv') clean_df=df.dropna() clean_df.loc[:, "Installs"] = clean_df.loc[:, "Installs"].astype(str).str.replace(",", "") clean_df.loc[:, "Installs"] = pd.to_numeric(clean_df.loc[:, "Installs"]) clean_df.loc[:,"Price"] = clean_df.loc[:,"Price"].astype(str).str.replace('$', "") clean_df.loc[:, "Price"] = pd.to_numeric(clean_df.loc[:,"Price"]) #Line 8: clean_df['Revenue_Estimate']= clean_df.Installs * clean_df.Price Error:
A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/s ... sus-a-copy clean_df['Revenue_Estimate']= clean_df.Installs * clean_df.Price =============
I tried this as well. did not work
df_apps_clean['Revenue_Estimate'] = df_apps_clean.Installs.mul(df_apps_clean.Price) Error:
A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/s ... sus-a-copy clean_df['Revenue_Estimate'] = clean_df.Installs.mul(clean_df.Price)
Источник: https://stackoverflow.com/questions/781 ... -in-python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение