99990/delete-column-from-pandas-dataframe-in-python
When deleting a column in a DataFrame I use:
del df['column_name']
And this works great. Why can't I use the following?
del df.column_name
Since it is possible to access the column/Series as df.column_name, I expected this to work.
As you've guessed, the right syntax is
It's difficult to make del df.column_name work simply as the result of syntactic limitations in Python. del df[name] gets translated to df.__delitem__(name) under the covers by Python.
Hi@akhtar, You can use the del command in ...READ MORE
You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE
You probably want to use np.ravel_multi_index: import numpy as ...READ MORE
You can use the rename function in ...READ MORE
The major difference is "size" includes NaN values, ...READ MORE
key error. I love python READ MORE
Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE
Use the original df1 indexes to create ...READ MORE
You can get the values as a ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.