Page 84 - IPP-12-2024
P. 84

day  temperature  windspeed  event
            5  01/01/2018           40          2  Sunny
            1  01/02/2018           41          7   Rain
            4  01/05/2018           41          7   Rain
            3  01/04/2018           42          4  Sunny
            0  01/01/2018           42          6  Sunny
            2  01/03/2018           43          2  Sunny
            Sorting on Multiple Columns one in ascending, another in descending
                      day  temperature  windspeed  event
            5  01/01/2018           40          2  Sunny
            1  01/02/2018           41          7   Rain
            4  01/05/2018           41          7   Rain
            0  01/01/2018           42          6  Sunny
            3  01/04/2018           42          4  Sunny
            2  01/03/2018           43          2  Sunny
            Sum Operations on Data Frame
            249
            Group By Operations
            windspeed
            2    83
            4    42
            6    42
            7    82
            Name: temperature, dtype: int64

            Program 13. Write a Program to read CSV file and show its data in python using DataFrames and
            pandas.
            Solution:
            import pandas as pd
            df=pd.read_csv("student.csv", nrows=3)
            print("To display selected number of rows from beginning")
            print(df)
            df=pd.read_csv("student.csv")
            print(df)
            print("Number of Rows and Columns")
            print(df.shape)
            print(df.head())
            print("Tail")
            print(df.tail(2))
            print("Specified Number of Rows")
            print(df[2:5])
            print("Print Everything")
            print(df[:])
            print("Print Column Names")
            print(df.columns)
            print("Data from Individual Column")
            print(df['Name']) #or df.Name
   79   80   81   82   83   84   85   86   87   88   89