exp1
exp1
Once you've installed numpy, you can perform some basic array
operations. Here's how you can explore some essential NumPy operations:
import numpy as np
print("Array:", arr)
# Array shape and size
print("Shape:", arr.shape)
print("Size:", arr.size)
# Array Operations
# Element-wise addition
# Statistical functions
print("Mean of array:", np.mean(arr))
To load the dataset into a pandas DataFrame, first ensure you have the
pandas library installed.
import pandas as pd
df = pd.read_csv(file_path)
print(df.head())
After loading the dataset into a DataFrame, you can select specific rows
and columns. Here's how you can do it:
Selecting Columns:
python
Copy code
Copy code
print(selected_columns.head())
Selecting Rows:
You can select specific rows using .iloc[] (by index) or .loc[] (by
label):
python
Copy code
print(df.iloc[9])
print(df[condition])
python
Copy code
# Filter data where Price is greater than 20,000 and Year is greater than
2015
print(filtered_data)
python
Copy code
# Select rows where Car Model is 'Toyota' and display 'Price' and 'Year'
columns
Summary: