Page 452 - AI Ver 3.0 class 10_Flipbook
P. 452

Pandas is highly flexible, allowing you to work with:

                 • Tabular data with heterogeneously-typed columns, like in an SQL table or Excel spreadsheet.
                 • Ordered and unordered time series data, which may not necessarily be of fixed frequency.
                 • Arbitrary matrix data, either homogeneous or heterogeneous, with row and column labels.
                 • A wide range of observational or statistical datasets.

              Installing Pandas


              To install Pandas from command line, we need to type in:
                                                          pip install pandas


              All libraries including NumPy and Pandas can be installed only when Python is already installed on that system.
              Two commonly used data structures in Pandas are:
                 • Series

                 • DataFrames
              Series


              Series is a one-dimensional array that can store data of any type like integer, string, float, python objects, etc.
              We can also say that the Pandas series is just like a column of a spreadsheet.
              The values can be referred to by using data axis labels also called index. Indexes are of two types: positional
              index and labelled index. Positional indexes are integers starting with default 0 whereas labelled indexes are user
              defined labels that can be of any datatype and can be used as an index.
              Pandas Series can be created by loading the datasets from existing storage like SQL Database, CSV file, and Excel
              file. Pandas Series can also be created from the lists, dictionary, and from any other scalar value.

              Creating Series

              Different ways of creating Series are:

                 • Creating an empty series

                 [1]:   import pandas as pd
                        Emp=pd.Series()
                 • Creating a Series from a NumPy array


                 [1]:   import pandas as pd
                        import numpy as np
                        data = np.array([10,30,50])
                        s1 = pd.Series(data)
                        print(s1)

                        0    10
                        1    30
                        2    50
                        dtype: int32








                    450     Touchpad Artificial Intelligence (Ver. 3.0)-X
   447   448   449   450   451   452   453   454   455   456   457