idek what chapter Flashcards
Series vs. DataFrames
series= 1d arrays
dataframes = 2d arrays
each of which have rows and columns which can be labelled
how to create series or dataframe
use python dictionary
define a dictionary
structure but mapping type (not a data sequence, so is indexed using keys)
is of type dict
mutable!
how to create a dictionary?
key-value pairs separated by commas, put in CURLY BRACKETS
bigguy = {‘keyname’:value_inside_key, ‘biggestguy’:’masonReilly}
how to index in a dictionary
dictionary[‘keyname’]
error if keyname DNE or index using integers
dictionary = mutable or not?
mutable (including modifying things inside it)
how to add/remove values to dictionary
dictionary[‘newkeyname’] = 123453241
del dictionary[‘nameofthingimremoving’]
len(mydictionary) returns?
amnt of key pairs
list(mydictionary) returns?
‘year’ in mydictionary returns?
returns the list equivalent
returns whether or not a key of that name exists in the dictionary
mydictionary = {‘year’:2313, ‘big’:’mason reilly’}
mydictionary.get(‘size’)
mydictionary.get(‘size’, -999)
mydictionary.get(‘big’}
what will these two getters return?
- None
- -999
- ‘mason reilly’
mydictionary.get()
mydictionary.get(‘keyname’)
mydictionary.get(‘keyname’, thing if keyname is not in dictionary)
why is get better than indexing a keyname?
indexing will return an error, get will return a value
dictionary pop
mydictionary.pop(‘name’)
mydictionary.pop(‘name’, thing if name DNE)
removes and returns removed value
error if no thing for DNE is specified and name DNE
dictionary popitem
mydict.popitem()
removes and returns last key of dictionary as a tuple
dictionary clear
mydict.clear()
clears all key-pairs from dictionary