Quantcast
Channel: Data Science, Analytics and Big Data discussions - Topics tagged data_science
Viewing all articles
Browse latest Browse all 787

Equality constraints

$
0
0

@shruti.bothe wrote:

Code:
df.loc[(df[‘SMS’] <19.44) | (df[‘CALL’] <16.21) | (df[‘INTERNET’] <194.14) , ‘REGION’]=1
df.loc[(df[‘SMS’] >=19.44) | (df[‘CALL’] >=16.21) | (df[‘INTERNET’] >=194.14) , ‘REGION’]=2
df.loc[(df[‘SMS’] <=185.39) | (df[‘CALL’] <=179.32) | (df[‘INTERNET’] <=1617.15) , ‘REGION’]=2
df.loc[(df[‘SMS’] >185.39) | (df[‘CALL’] >179.32) | (df[‘INTERNET’] >1617.15) , ‘REGION’]=3
df.head()

output:
ID SMS CALL INTERNET POI REGION

1.0       2.664773      0.733324      62.899977             0              2
1.0       1.925665      0.492015      54.051207             0              2
1.0       1.479944      0.220799      45.901909             0              2

Here the values of region should be 1 and not 2.

But when I write the code below, it gives me the values of 1

df.loc[(df['SMS'] <19.44) | (df['CALL'] <16.21) | (df['INTERNET'] <194.14) , 'REGION']=1

df.head()

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 787

Trending Articles