cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How can I remove a key from a Python dictionary?

Kaniz
Community Manager
Community Manager
 
3 REPLIES 3

spark-user
Contributor

Hi Kaniz,

You can remove it by using the pop method

dict.pop('key', None)

It is a safe way to delete a key even if you are not sure it exists. The second parameter is optional also.

You can read more about the method here.

 Thank you

Kaniz
Community Manager
Community Manager

Thank you @spark-user.

No problem!

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.