December 2017
Intermediate to advanced
386 pages
10h 42m
English
We can think of a DataFrame as a dictionary, where the dictionary keys are the column names. So, to insert a column, we can use the following code:
df['column_name'] = <iterable>
The <iterable> can be for example, a list, a NumPy array, or a pandas Series object. Analogously, to delete a column we can use the Python del operator, as follows:
del df['column_name']
Read now
Unlock full access