Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas loc condition

>>> df.loc[(df["B"] > 50) & (df["C"] == 900), "A"]
2    5
3    8
Name: A, dtype: int64
>>> df.loc[(df["B"] > 50) & (df["C"] == 900), "A"].values
array([5, 8], dtype=int64)
>>> df.loc[(df["B"] > 50) & (df["C"] == 900), "A"] *= 1000
>>> df
      A   B    C
0     9  40  300
1     9  70  700
2  5000  70  900
3  8000  80  900
4     7  50  200
5     9  30  900
6     2  80  700
7     2  80  400
8     5  80  300
9     7  70  800
Comment

panda loc conditional

df.loc[df['shield'] > 6]
            max_speed  shield
sidewinder          7       8
Comment

PREVIOUS NEXT
Code Example
Python :: lastindexof python 
Python :: get local ip 
Python :: How to read PDF from link in Python] 
Python :: get random number positive or negative python 
Python :: set an index to a dataframe from another dataframe 
Python :: read data from excel and plot in python 
Python :: python empty constructor 
Python :: python dictonary set default 
Python :: spark df to pandas df 
Python :: boids algorithm 
Python :: lcm in python 
Python :: how to take first digit of number python 
Python :: pandas read to a csv file 
Python :: Setting up Colab for Kaggle Downloads 
Python :: list element swapping python 
Python :: mulitplication symbo for unpacking in python 
Python :: how to make a leaderboard in python 
Python :: readlines replace  
Python :: python extract string 
Python :: os chdir python 
Python :: get file size python 
Python :: telegram bot webhook python 
Python :: IndentationError: unexpected indent 
Python :: python file write 
Python :: break python 
Python :: if condition dataframe python 
Python :: convert pandas.core.indexes.numeric.int64index to list 
Python :: how to add python interpreter in vscode 
Python :: ip validity checker python 
Python :: python requests-session for websites with login 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =