Python, with its simplicity and versatility, has become a go-to language for data analysis. Its rich ecosystem offers libraries like NumPy, Pandas, Matplotlib, and Scipy, which streamline data manipulation, analysis, and visualization. Let's dive into creating a simple Python program for data analysis using these powerful tools.

First, we'll ensure our environment is ready. Install the required libraries using pip:

pip install numpy pandas matplotlib scikit-learn
Data Manipulation and Cleaning

Data analysis often starts with acquiring and cleaning data. Pandas provides DataFrame, a 2-D labeled data structure with columns of potentially different types. It's excellent for manipulating tabular data.
Let's load and explore a simple CSV dataset:

Importing and Exploring Data
First, import the necessary libraries:
import pandas as pd
import numpy as np

Loading and Exploring Data
Next, load a CSV file into a DataFrame:
data = pd.read_csv('data.csv')

Inspect the first five rows with:
print(data.head())




















Check the data types and number of non-null values:
print(data.info())
Data Cleaning and Preprocessing
Real-world data often contains missing values, duplicates, or inconsistent data. Let's handle these issues.
Handling Missing Values
Fill missing numeric data with the mean using:
df['column_name'].fillna(df['column_name'].mean(), inplace=True)
Fill missing categorical data with the mode:
df['column_name'].fillna(df['column_name'].mode()[0], inplace=True)
Removing Duplicates
Remove duplicate rows based on a specific column:
df.drop_duplicates(subset='column_name', inplace=True)
Or drop duplicates based on all columns:
df.drop_duplicates(inplace=True)
Data Analysis and Visualization
Now that our data is clean, we can analyze and visualize it. Matplotlib and Seaborn libraries offer extensive plotting capabilities.
Plotting Data
Let's create a simple bar chart. First, import the necessary libraries:
import matplotlib.pyplot as plt
Then, create a bar chart:
data['column_name'].value_counts().plot(kind='bar')
Add a title and rotate xticks:
plt.title('Column Name Distribution')
plt.xticks(rotation=0)
Finally, display the plot:
plt.show()
Exploratory data analysis involves iterating and trying different visualizations to understand data better.
Python's simplicity and extensive libraries make it an ideal choice for data analysis. Start with small scripts, then scale up as you gain confidence and familiarity.
Whether you're a seasoned analyst or a beginner, unlocking the power of Python for data analysis is a rewarding journey. Happy coding!