Page 260 - AI Computer 10
P. 260

Example 4: Program to create 2D array of 4 rows and 5 columns with all ones as value.

                 import numpy as np
                 a = np.ones((4,5))
                 print(a)

            Output:
                 [[1. 1. 1. 1. 1.]
                 [1. 1. 1. 1. 1.]
                 [1. 1. 1. 1. 1.]
                 [1. 1. 1. 1. 1.]]
            Example 5: Program to create 2D array of 4 rows and 5 columns with all zeros as value.

                 import numpy as np
                 a = np.zeros((4,5))
                 print(a)

            Output:
                 [[0. 0. 0. 0. 0.]
                 [0. 0. 0. 0. 0.]
                 [0. 0. 0. 0. 0.]
                 [0. 0. 0. 0. 0.]]

            Example 6: Program to create 2D array of 2 rows and 3 columns with all value as 5.
                 import numpy as np
                 a = np.full((2,3),5)
                 print(a)
            Output:

                 [[5 5 5]
                 [5 5 5]]

            Pandas

            Pandas is a popular Python package for data science because it offers
            powerful,  expressive,  and flexible  data structures  that make  data
            manipulation and analysis easy, among many other things.

            It was developed in 2008 when a programmer required a high performance, flexible tool for data analysis.
            The Pandas have two main structures i.e.,Series (1-dimensional) and DataFrame (2-dimensional) that handle the
            vast majority of typical use cases in finance, statistics, social science, and many areas of engineering. Pandas is
            built on top of NumPy and is intended to integrate well within a scientific computing environment with many
            other third party libraries.The important features of Pandas are as follows:
             u Fast and efficient DataFrame object to manage and explore data.
             u Organisation and labelling of data are perfectly done by the intelligent methods of alignment and indexing
             u Integrated handling of missing data values.

             u Optimisation of performance.
             u Columns from a data structure can be deleted or inserted.
             u Group by data for aggregation and transformations.
             u Easy implementation of mathematical operation on the datasets.

                126
                126
   255   256   257   258   259   260   261   262   263   264   265