본문 바로가기
Tech/Python

pandas - Basic DataFrame Inspection

by Jyubaeng2 2023. 7. 30.

Data Import

import pandas as pd
from sklearn.datasets import load_boston

# Load the Boston Housing Prices dataset
boston = load_boston()
boston_df = pd.DataFrame(boston.data, columns=boston.feature_names)
boston_df['PRICE'] = boston.target

Inspect DataFrame

First Few Rows of the DataFrame: This will show the first few rows of the DataFrame, which will include both the input features (columns from boston.feature_names) and the target variable 'PRICE'.

boston_df.head(10)

boston_df.shape

DataFrame Information: This will display details such as the total number of rows, column names, data types, and memory usage.

boston_df.info()

 

DataFrame Statistical Summary: This will provide basic statistics for each numerical column in the DataFrame, such as count, mean, standard deviation, minimum, 25th percentile, median (50th percentile), 75th percentile, and maximum.

boston_df.describe()

 

.values will show data only.

boston_df.values

.columns will show column names.

boston_df.columns

 

.index will show the row indexes

boston_df.index

 

https://ai-fin-tech.tistory.com/entry/Sorting-DataFrame-with-pandas

 

Sorting DataFrame with pandas

Data Import import pandas as pd from sklearn.datasets import load_boston # Load the Boston Housing Prices dataset boston = load_boston() boston_df = pd.DataFrame(boston.data, columns=boston.feature_names) boston_df['PRICE'] = boston.target Sorting DataFram

ai-fin-tech.tistory.com

 

'Tech > Python' 카테고리의 다른 글

pandas - Complete Usage of loc and iloc  (1) 2023.07.30
pandas - Subsetting Columns and Rows  (1) 2023.07.30
pandas - Sorting DataFrame  (1) 2023.07.30
pandas - Data Import  (1) 2023.07.30
기계 학습을 위한 무료 데이터셋 Top 3  (2) 2023.07.30

댓글