Manipulating Data Frames in Python

Manipulating Data Frames in Python

 

Manipulating Data Frames in Python, in this article i will show you how to manipulate imported data frames into python

  1. Deleting Column
  2. Deleting bunch of Column
  3. Deleting Row
  4. Deleting bunch of Row
  5. Adding Column
  6. Tran-pose Data Frame
  7. Adding a new Row

Deleting Column

  • df1.drop(“City”,1)

 

Deleting Bunch of Column

  • df1.drop(df1.columns[0:3],1)

 

Deleting Rows

  • df1.drop(98797,0)

Deleting Bunch Rows

  • df1.drop(df1.set_index[0:3],0)

Adding Columns

  • df1[“Salary”]=df1.shape[0]*[“$5000”]

Tran-pose Data Frame

  • df1.T
  • This will turn row into column , and column into row

Adding Row

  • Before Adding Row , first you will need to trans-pose the Data Set
  • Then Just like Adding the Column Data, input which ever data you want it to be resided in the Columns
  • Trans-pose the Data Frame again

 

Check out slicing and indexing DataFrame here

 

 

Leave a Comment

one + 9 =