Assignment 4 5
Assignment 4 5
The Data Is :
Year Industry_aggregation_NZSIOC Industry_code_NZSIOC \
0 2023 Level 1 99999
1 2023 Level 1 99999
2 2023 Level 1 99999
3 2023 Level 1 99999
4 2023 Level 1 99999
... ... ... ...
50980 2013 Level 3 ZZ11
50981 2013 Level 3 ZZ11
50982 2013 Level 3 ZZ11
50983 2013 Level 3 ZZ11
50984 2013 Level 3 ZZ11
Industry_name_NZSIOC Units Variable_code \
0 All industries Dollars (millions) H01
1 All industries Dollars (millions) H04
2 All industries Dollars (millions) H05
3 All industries Dollars (millions) H07
4 All industries Dollars (millions) H08
... ... ... ...
50980 Food product manufacturing Percentage H37
50981 Food product manufacturing Percentage H38
50982 Food product manufacturing Percentage H39 50983 Food
product manufacturing Percentage H40
50984 Food product manufacturing Percentage H41
Variable_name Variable_category \
0 Total income Financial performance
1 Sales, government funding, grants and subsidies Financial
performance
2 Interest, dividends and donations Financial performance
3 Non-operating income Financial performance
4 Total expenditure Financial performance
... ... ...
50980 Quick ratio Financial ratios
50981 Margin on sales of goods for resale Financial ratios
50982 Return on equity Financial ratios
50983 Return on total assets Financial ratios
50984 Liabilities structure Financial ratios
Value Industry_code_ANZSIC06
0 930995 ANZSIC06 divisions A-S (excluding classes K633...
1 821630 ANZSIC06 divisions A-S (excluding classes K633...
2 84354 ANZSIC06 divisions A-S (excluding classes K633...
3 25010 ANZSIC06 divisions A-S (excluding classes K633...
4 832964 ANZSIC06 divisions A-S (excluding classes K633...
... ... ...
50980 52 ANZSIC06 groups C111, C112, C113, C114, C115, ...
50981 40 ANZSIC06 groups C111, C112, C113, C114, C115, ...
50982 12 ANZSIC06 groups C111, C112, C113, C114, C115, ...
50983 5 ANZSIC06 groups C111, C112, C113, C114, C115, ...
50984 46 ANZSIC06 groups C111, C112, C113, C114, C115, ...
Units Variable_code \
0 Dollars (millions) H01
1 Dollars (millions) H04
Variable_name Variable_category \
0 Total income Financial performance
1 Sales, government funding, grants and subsidies Financial
performance
Value Industry_code_ANZSIC06
0 930995 ANZSIC06 divisions A-S (excluding classes K633...
1 821630 ANZSIC06 divisions A-S (excluding classes K633...
The Bottom Two Lines of the Data Are :
Year Industry_aggregation_NZSIOC Industry_code_NZSIOC \
50983 2013 Level 3 ZZ11
50984 2013 Level 3 ZZ11
Industry_code_ANZSIC06
50983 ANZSIC06 groups C111, C112, C113, C114, C115, ...
50984 ANZSIC06 groups C111, C112, C113, C114, C115, ...
The Shape of the Data Are :
(50985, 10)
The Type of Data Are :
<class 'pandas.core.frame.DataFrame'>
The Total Number of Observations in the Data Are :
50985
The Total Number of Missing Values Are :
0
The Total Number of Nan Values Are :
0
DEPARTMENT OF MECHANICAL ENGINEERING
Data Analytics Lab
Assignment No. 5
CODE:
from sklearn.datasets import load_iris iris=load_iris()
print('Keys of The Data Set :\n',iris.keys()) print('\nNumber of
Rows and Columns :\n', iris.data.shape) print('\nColumn
Names :\n', iris.feature_names) print('\nDataset Description
:\n', iris.DESCR)
OUTPUT:
Keys of The Data Set :
dict_keys(['data', 'target', 'frame', 'target_names', 'DESCR', 'feature_names',
'filename', 'data_module'])
Dataset Description :
.. _iris_dataset:
:Summary Statistics:
The famous Iris database, first used by Sir R.A. Fisher. The dataset is taken from
Fisher's paper. Note that it's the same as in R, but not as in the UCI Machine
Learning Repository, which has two wrong data points.
|details-end|
CODE:import numpy as np from scipy.sparse import csr_matrix
dense_matrix=np.eye(3)
sparse_matrix=csr_matrix(dense_matrix) print(sparse_matrix)
iris_df=pd.read_csv('/Iris.csv') print(iris_df)
iris_df_modified=iris_df.drop(columns=['Id']) print("\n
Modified Data Frame (Without 'Id' Column) :")
print(iris_df_modified) iris_df_modified=iris_df.drop(index=2)
print(iris_df_modified) Output : (0, 0) 1.0
(1, 1) 1.0
(2, 2) 1.0
Id SepalLengthCm SepalWidthCm PetalLengthCm
PetalWidthCm \
0 1 5.1 3.5 1.4 0.2
1 2 4.9 3.0 1.4 0.2
2 3 4.7 3.2 1.3 0.2
3 4 4.6 3.1 1.5 0.2
4 5 5.0 3.6 1.4
0.2
.. ... ... ... ... ...
145 146 6.7 3.0 5.2 2.3
146 147 6.3 2.5 5.0 1.9
147 148 6.5 3.0 5.2 2.0
148 149 6.2 3.4 5.4 2.3
149 150 5.9 3.0 5.1 1.8
Species
0 Iris-setosa
1 Iris-setosa
2 Iris-setosa
3 Iris-setosa
4 Iris-setosa
.. ...
145 Iris-virginica
146 Iris-virginica
147 Iris-virginica
148 Iris-virginica
149 Iris-virginica
Species
0 Iris-setosa
1 Iris-setosa
3 Iris-setosa
4 Iris-setosa
5 Iris-setosa
.. ...
145 Iris-virginica
146 Iris-virginica
147 Iris-virginica
148 Iris-virginica
149 Iris-virginica
[149 rows x 6 columns]
CODE:iris_df_modified=iris_df.drop(columns=['Id']) print("\n
Modified Data Frame (Without 'Id' Column) :")
print(iris_df_modified)
iris_df_modified=iris_df.drop(index=2)
print(iris_df_modified)
Output : Modified Data Frame (Without 'Id' Column) :
SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm
Species
0 5.1 3.5 1.4 0.2 Iris-setosa
1 4.9 3.0 1.4 0.2 Iris-setosa
2 4.7 3.2 1.3 0.2 Iris-setosa
3 4.6 3.1 1.5 0.2 Iris-setosa
4 5.0 3.6 1.4 0.2 Iris-setosa
.. ... ... ... ... ...
145 6.7 3.0 5.2 2.3 Iris-virginica
146 6.3 2.5 5.0 1.9 Iris-virginica
147 6.5 3.0 5.2 2.0 Iris-virginica
148 6.2 3.4 5.4 2.3 Iris-virginica
149 5.9 3.0 5.1 1.8 Iris-virginica
Species
0 Iris-setosa
1 Iris-setosa
3 Iris-setosa
4 Iris-setosa
5 Iris-setosa
.. ...
145 Iris-virginica
146 Iris-virginica
147 Iris-virginica
148 Iris-virginica
149 Iris-virginica