0% found this document useful (0 votes)
5 views4 pages

DRA Lab Exp1

The document describes a Python program that uses the NumPy module to reshape a dataset containing environmental measurements of Temperature, Humidity, and Pressure. It includes source code for loading a CSV file into a pandas DataFrame, converting it to a NumPy array, and reshaping the data. The program successfully executes and displays the original dataset, the converted NumPy array, and the reshaped data array.

Uploaded by

bborigarla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

DRA Lab Exp1

The document describes a Python program that uses the NumPy module to reshape a dataset containing environmental measurements of Temperature, Humidity, and Pressure. It includes source code for loading a CSV file into a pandas DataFrame, converting it to a NumPy array, and reshaping the data. The program successfully executes and displays the original dataset, the converted NumPy array, and the reshaped data array.

Uploaded by

bborigarla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DATE:

EXPRIMENT-1
NUMPY MODULE FOR RESHAPPING
AIM: To implement python program by using numpy module for reshaping.

SOURCE CODE:

import pandas as pd

import numpy as np

# Specify the CSV file (assumed to be in the same directory)

csv_file = 'data.csv'

# Load the CSV file into a pandas DataFrame

df = pd.read_csv(csv_file)

# Display the original dataset

print("Original Dataset:")

print(df)

# Convert the DataFrame to a NumPy array

data_array = df.to_numpy()

# Display the dataset in NumPy array format

print("\nConverted to NumPy Array:")

print(data_array)

# Reshape the NumPy array (example: keeping 5 rows and automatically adjusting columns)

reshaped_array = data_array.reshape(5, -1)

# Display the reshaped NumPy array

print("\nReshaped Data Array:")

print(reshaped_array)
DATASET DESCRIPTION:

This dataset contains three key environmental measurements: Temperature, Humidity, and
Pressure. These attributes are commonly used in weather analysis and environmental monitoring.
 Temperature: The measure of heat in degrees Celsius.
 Humidity: The percentage of moisture in the air.
 Pressure: The atmospheric pressure measured in hPa (hectopascals).
The data consists of 5 entries, each representing different environmental conditions:

Temperature (°C) Humidity (%) Pressure (hPa)

22 45 1012
25 50 1008
21 40 1015
30 55 1005
28 60 1009

OUTPUT:

Original Dataset:
Temperature (°C) Humidity (%) Pressure (hPa)
22 45 1012
25 50 1008
21 40 1015
30 55 1005
28 60 1009

Converted to NumPy Array:

[[ 22 45 1012]

[ 25 50 1008]

[ 21 40 1015]

[ 30 55 1005]

[ 28 60 1009]]
Reshaped Data Array:

[[ 22 45 1012 25 50 1008]

[ 21 40 1015 30 55 1005]

[ 28 60 1009]]

RESULT:
Numpy module for reshaping using Temperature,Humidity and Pressure data set is successfully executed.

You might also like