Skip to main content
Formatted code, minor tweaks to grammar
Source Link
Alex Riley
  • 178.3k
  • 46
  • 274
  • 247

You could provide a list of columns to be dropped and return back the dataframeDataFrame with only the columns needed using the drop()drop() function on a pandas dataframePandas DataFrame.

Just saying colsToDrop = ['a']
df.drop(colsToDrop, axis=1)

colsToDrop = ['a']
df.drop(colsToDrop, axis=1)

would return a dataframeDataFrame with just the columns bb and cc.

The drop method is documented http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop.htmlhere.

You could provide a list of columns to be dropped and return back the dataframe with only the columns needed using the drop() function on a pandas dataframe.

Just saying colsToDrop = ['a']
df.drop(colsToDrop, axis=1)

would return a dataframe with just the columns b and c.

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop.html

You could provide a list of columns to be dropped and return back the DataFrame with only the columns needed using the drop() function on a Pandas DataFrame.

Just saying

colsToDrop = ['a']
df.drop(colsToDrop, axis=1)

would return a DataFrame with just the columns b and c.

The drop method is documented here.

Source Link

You could provide a list of columns to be dropped and return back the dataframe with only the columns needed using the drop() function on a pandas dataframe.

Just saying colsToDrop = ['a']
df.drop(colsToDrop, axis=1)

would return a dataframe with just the columns b and c.

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop.html