Table with 10+ columns. Every cell in subject column has 3 elements: 1) address, 2) city-state-zip, 3) coordinates.
How to remove elements 1 & 2 and leave coordinates only without hooks?
After creating the new columns as detailed in my answer to your previous question , you can simply use the drop
method from pandas to delete the ones you don't want to keep. For example, if you want to drop the address and the col1 columns, you just write:
df.drop(['address', 'col1'], axis=1, inplace = True)
We use the inplace flag so that the columns are deleted from the dataframe. Otherwise, we would need to write something like:
df = df.drop(['address', 'col1'], axis=1)
because the command returns a new dataframe with the deleted columns. Here 's the documentation. Give it a look. It is super complete.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.