{"a":1,"b":2,"c":3} This time a,b,c→key 1,2,3→value Say.
ta=df["a"]
>>>print(ta)
Execution result
>>>1
Use key to retrieve element (value) like this
df["a"]=4
>>>print(df)
Reference result
>>>{"a":4,"b":2,"c":3}
Same as how to retrieve elements
df.setdefault("d",4)
>>>print(df)
Execution result
>>>{"a":1,"b":2,"c":3,"d":4}
You can add it by using setdefault (key, value) like this.
df.pop("d")
>>>print(df)
Execution result
>>>{"a":1,"b":2,"c":3}
You can delete it by using pop (key) like this
Recommended Posts