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 :: python greater than dunder 
Python :: create an array filled with 0 
Python :: Display shape of the DataFrame 
Python :: jacobi iteration method python 
Python :: check command 
Python :: python dict to string 
Python :: python tkinter importieren 
Python :: python black 
Python :: python histogram one liners 
Python :: python subtract between list 
Python :: python generator function 
Python :: how to take first half of list python 
Python :: Working with WTForms FieldList 
Python :: reshape (-1,1) 
Python :: 12 month movinf average in python for dataframe 
Python :: model.predict knn 
Python :: trim strings python 
Python :: geopandas replace column name 
Python :: python if file exist 
Python :: how to pre populate field flask wtforms 
Python :: remove element from pack tkinter 
Python :: make virtual environment python 
Python :: how to define number in python 
Python :: get hours from datetime.timedelta in python (Django) 
Python :: tensorflow create custom initializer 
Python :: string remove suffix python 
Python :: python catch int conversion error 
Python :: python strftime cheat sheet 
Python :: flask windows auto reload 
Python :: get table wikipedia 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =