Can someone please explain in an elaborative way what is the role of .get() function.
Also please explain in the context of code pasted below from the FDS hands on session.
short_names = {}
for s in df.method.unique():
short_names[s] = ''.join([x[0] for x in s.split(' ')])
print (short_names)
for i, r in df.iterrows():
df.loc[i, 'short_method'] = short_names.get(r['method'], r['method'])
Above is the code for reference. Please explain what does r[ ‘method’ ] refer to and what happens when written twice vs when written once?(i know it gives null value if second parameter is missing and the value is null but i am not able to understand in the context of this code like how does it work actually?)