Data Frames in Pandas - 2D Array

     

  • It is a two dimentional data structure
  •  

     

  • It is represented in tabular format
  •  

  • It consists of row index and column index
  •  

     

  • df.columns, denotes about columns
  •  

  • df.index, denotes about rows
  •  

    Structure of Data Frame:

     

     

    Source to create DataFrames:

     

  • Lists
  • Dictionaries
  • Series
  • Numpyndarrays
  • Create one Dataframe to another
  •  

    DataFreame sysntax:

     

     

     

    Data Frames with Dictionaries

     

  • If data represents to list we need to mention the column headers, whereas data is in form of DICTIONARY, KEY value is conidered as column Headers
  •  

     

    Craete Dataframe without providing values to Index

     

     

    Craete Dataframe after providing values to Index

     

     

    Row index and column Headers

     

     

    Retrieve all the values\rows

     

     

    Retrieve all the values\rows

     

     

    Row slicing

     

     

    Row slicing - multiple rows

     

     

    Row slicing - all rows

     

     

    Dataframe - column slicing - single column

     

     

     

    Dataframe - Delete a column

     

     

     

    Dataframe - row slicing and column slicing

     

     

    Dataframe - Apply condition on a column

     

     

    Dataframe - Transpose

     

     

    Dataframe - Add new column with insufficient data

    import pandas as pd
    import numpy as np
    df = pd.DataFrame([5,6], index = ['apple','banana'])
    ser = pd.Series([15], index = ['apple'])
    df['grapes']=ser
    print(df)

     

    Slice the Dataframe based on criteria

     

    Pandas - Split the frame based on condition

     

     

    Create Dataframe with multiple lists

     

    Pandas_Create_Data_Frame_with_Nested_List

     

     

    Pandas Download

  • click on below mentioned image to download: