DRA Lab Exp8
DRA Lab Exp8
EXPRIMENT-8
DATAFRAME OBJECTS
AIM: To develop python program for dataframe objects.
SOURCE CODE:
import pandas as pd
df = pd.read_csv('data.csv')
print("Original dataset:")
print(df.head())
print("\nDataset information:")
print(df.info())
print(df.isnull().sum())
print(df.describe())
# Step 6: Select specific columns (adjust column names as per your dataset)
print("\nSelected columns:")
print(selected_columns.head())
print(filtered_df.head())
print(df.head())
filtered_df.to_csv('filtered_data.csv', index=False)
DATASET DESCRIPTION:
This dataset contains basic information about a few individuals, including their names, ages, cities, and
annual incomes. Each row in the dataset represents one person.
Columns
1. Name: The person’s first name (e.g., Alice, Bob).
2. Age: The person’s age in years (e.g., 24, 27).
3. City: The city where the person lives (e.g., New York, Chicago).
4. Income: The person’s annual income in USD (e.g., 72000, 82000)
Data give below:
OUTPUT:
Original dataset:
Dataset information:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Name 5 non-null object
1 Age 5 non-null int64
2 City 5 non-null object
3 Income 5 non-null int64
dtypes: int64(2), object(2)
memory usage: 136.0 bytes
Selected columns:
Age Income
24 72000
27 82000
22 65000
32 91000
29 60000
Filtered data where Age > 25: