Basics of Pandas

     

    Number of rows and columns

  • list(df.shape)
  • Denotes about the number of rows and columns of shape, and saved in a list

    {{rowsandcolumns}}

     

    Number of rows in dataframe

  • rowsandcolumns = list(df.shape)
  • rows = rowsandcolumns[0]
  • {{rows}}

    Number of columns in dataframe

  • columns = rowsandcolumns[1]
  • {{columns}}

  • colscount = len(df.columns) {{colscount}}

     

    To print the column Headers of dataframe in a List

  • columnHeaders = list(df.columns)
  • {{columnHeaders}}

     

    To print the values of dataframe and save in a List

  • values = df.values
  • {{values}}

     

    To print the row index range

  • To print the row index range from start to end
  • rowindexrange = df.index
  • {{rowindexrange}}

     

    To print the row index range in List

  • To print the row index in a list
  • {{rowindexrangeInList}}

     

    To print number of rows in dataframe

  • print(len(df)) # to find the number of rows in dataframe
  • {{NumberOfRows}}

    Select the columns

     

  • cols = df.columns
  • It returns the column headers
  •  

    {{cols}}

     

    Return column headers as List

     

  • TotalColumnList = df.columns.tolist()
  • Returns all the column headers as List
  • {{TotalColumnList}}

     

  • Select the values
  • values denotes about the dataframe except headers
  • values = df.values
  •  

    {{values}}

     

    column header of first column

     

    {{columnheader}}

     

    print column as Object

     

    {{colobj}}

     

    print column in List

     

    {{columnsInlist}}