0
0
Data Analysis Pythondata~5 mins

Basic DataFrame info (shape, dtypes, describe) in Data Analysis Python

Choose your learning style9 modes available
Introduction

We use basic DataFrame info to quickly understand the size, types, and summary of our data. This helps us know what we have before analyzing.

When you first load a dataset and want to see how many rows and columns it has.
When you want to check the type of data in each column (numbers, text, dates).
When you want a quick summary of statistics like mean, min, max for numeric columns.
When you want to find missing or unusual values by looking at data summaries.
When preparing data for cleaning or visualization and need a quick overview.
Syntax
Data Analysis Python
df.shape

df.dtypes

df.describe()

df.shape returns a tuple with (rows, columns).

df.dtypes shows the data type of each column.

df.describe() gives summary stats for numeric columns by default.

Examples
Prints the number of rows and columns as a tuple.
Data Analysis Python
print(df.shape)
Shows the data type of each column, like int64, float64, object (text).
Data Analysis Python
print(df.dtypes)
Displays count, mean, std, min, max, and quartiles for numeric columns.
Data Analysis Python
print(df.describe())
Shows summary statistics for all columns, including text columns.
Data Analysis Python
print(df.describe(include='all'))
Sample Program

This code creates a small table with Age, Name, and Salary columns. It then prints the size, data types, and summary stats for the numeric columns.

Data Analysis Python
import pandas as pd

# Create a simple DataFrame
 data = {
     'Age': [25, 30, 22, 40, 28],
     'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva'],
     'Salary': [50000, 60000, 45000, 80000, 52000]
 }

df = pd.DataFrame(data)

# Print shape
print('Shape:', df.shape)

# Print data types
print('\nData types:')
print(df.dtypes)

# Print summary statistics
print('\nSummary statistics:')
print(df.describe())
OutputSuccess
Important Notes

Remember: describe() by default only summarizes numeric columns.

You can use df.info() for a quick overview including non-null counts and memory usage.

Summary

Use df.shape to see how big your data is.

Use df.dtypes to check what kind of data each column holds.

Use df.describe() to get quick stats on numeric data.