Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

loc pandas df

df.loc[df['shield'] > 35] = 0
Comment

pd.loc

>>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
...      index=['cobra', 'viper', 'sidewinder'],
...      columns=['max_speed', 'shield'])
>>> df
            max_speed  shield
cobra               1       2
viper               4       5
sidewinder          7       8

>>> df.loc[['viper', 'sidewinder']]
            max_speed  shield
viper               4       5
sidewinder          7       8
Comment

df loc

df.loc['viper']
Comment

df loc

df.loc[:, 'max_speed'] = 30
Comment

pandas data.loc

df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
...      index=['cobra', 'viper', 'sidewinder'],
...      columns=['max_speed', 'shield'])
Comment

pandas data.loc

df.loc['viper']
max_speed    4
shield       5
Comment

pandas data.loc

df.loc['cobra', 'shield']
2
Comment

pandas data.loc

df.loc['cobra':'viper', 'max_speed']
cobra    1
viper    4
Name: max_speed, dtype: int64
Comment

pandas data.loc

df.loc[[False, False, True]]
            max_speed  shield
sidewinder          7       8
Comment

pandas data.loc

df.loc[pd.Series([False, True, False],
...        index=['viper', 'sidewinder', 'cobra'])]
            max_speed  shield
sidewinder          7       8
Comment

PREVIOUS NEXT
Code Example
Python :: sonido sfr200a 
Python :: how to filter csv file by columns 
Python :: initialise tuple in python 
Python :: while attempts 0: 
Python :: implementing a bubble sort in python 
Python :: representation of multidimensional array in data structure 
Python :: check if cuda is present in torch 
Python :: how to convert array value to integer in python 
Python :: python sum 1-50 
Python :: kivy lang 
Python :: open file rw python 
Python :: tensorflow tf.constant 
Python :: pandas drop unnamed columns grebber 
Python :: leetcode 206 python 
Python :: convert pb to tb with python 
Python :: matplotlib set dpi 300 
Python :: python image resize 
Python :: ipython list command history 
Python :: tkinter sin 
Python :: onetomany field 
Python :: unhexing floats 
Python :: socket python how to check if server alive 
Python :: remove item from list python grepper 
Python :: pandas dexcribe only one column 
Python :: customise django admin edit model button in field 
Python :: quicksort python 
Python :: dataset.shape 
Python :: convert pine script to python online 
Python :: django messages framework 
Python :: python label 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =