Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

new column in pandas with where logic

virtsizes = {
  "type1": { "gb": 1.2, "xxx": 0, "yyy": 30 },
  "type2": { "gb": 1.5, "xxx": 2, "yyy": 20  },
  "type3": { "gb": 2.3, "xxx": 0.1, "yyy": 10  },
}
d = {k:v['gb'] for k,v in virtsizes.items()}
print (d)
{'type2': 1.5, 'type1': 1.2, 'type3': 2.3}

df = pd.DataFrame({'vol-type':['type1','type2']})
df["real_size"] = df["vol-type"].map(d)
print (df)
  vol-type  real_size
0    type1        1.2
1    type2        1.5
Comment

PREVIOUS NEXT
Code Example
Python :: Add up the elements in this RDD 
Python :: how to let the user input desmials in python 
Python :: ciclo while python 
Python :: pyqt5 how to see if clipboard is empty 
Python :: arrotondamento python 
Python :: python compressed for concatenate string 
Python :: pyfcm image 
Python :: access data frame element by loc 
Python :: assert vs validate in python 
Python :: getting range lowest and highest values from np array 
Python :: torch print floating precision 
Python :: tkinter app example code 
Python :: convert python to c++ online 
Python :: python != 
Python :: gtk entry focus python 
Python :: !python read data from mysql and export to xecel 
Python :: difference between changing values of variable and list inside function in python 
Python :: query json array 
Python :: Dateien mit modul requests herunterladen python 
Python :: weighted averae multiple columns 
Python :: what is enumerate in python 
Python :: capturing-video-from-two-cameras-in-opencv-at-once 
Python :: arrow.get(null) 
Python :: initial TypedMultipleChoiceField django 
Python :: to find keywords in a text spacy 
Python :: list value extraction using python 
Python :: region error when use service account json file dataproc 
Python :: Python: Sending a variable to another script 
Python :: value counts normalize 
Python :: python modules screen 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =