0

I have the following Python code:

import os.path
import pandas as pd
import numpy as np
import time
import requests

df = pd.DataFrame({'ISIN':['US02079K3059', 'US02079K3059', 'US02079K3059', 'US02079K3059', 'US02079K3059', 'US02079K3059', 'US02079K3059', 'US02079K3059', 'US00206R1023'],
               'Name':['ALPHABET INC.CL.A DL-,001', 'Alphabet Inc Class A', 'ALPHABET INC CLASS A', 'ALPHABET A', 'ALPHABET INC CLASS A', 'ALPHABET A', 'Alphabet Inc. Class C', 'Alphabet Inc. Class A', 'AT&T Inc'], 
               'Country':['United States', 'United States', 'United States', '', 'United States', 'United States', 'United States', 'United States', 'United States'],
               'Category':[ '', 'big', 'big', '', 'big', 'test', 'test', 'test', 'average'],
               'Category2':['important', '', 'important', '', '', '', '', '', 'irrelevant'],
               'EV_Sales':[-5.23, '', 60, 15.3, 15, 9.00, 398.21, '', 1]})

df['EV_Sales'] = pd.to_numeric(df['EV_Sales'], errors='coerce')

if df['EV_Sales'] >= 15:
df['WS_EV_Sales'] = -1
else:
df['WS_EV_Sales'] = 0

As you can see I try to generate the column WS_EV_Sales depending on the value of ['EV_Sales']. Unfortunately the following error is returned as a result:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

How can I solve the problem? Any suggestions?

0 Answers0