-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPandas
More file actions
41 lines (30 loc) · 802 Bytes
/
Copy pathPandas
File metadata and controls
41 lines (30 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#A project that involves Data cleaning and visualization
#using pandas and matplotlib
import pandas as pd
import matplotlib.pyplot as plt
#reading the csv file
df=pd.read_csv('data.csv')
print(df)
print(' ')
#Data cleaning or cleaning the missing values
cleaned_data=df.dropna()
print(cleaned_data)
print(' ')
#print few records from the cleaned data
print(cleaned_data.head())
print(' ')
#info or cleaned data
print(cleaned_data.info())
print(' ')
#Descriptive statistics...
print('Descriptive statistics: ')
print(cleaned_data.describe())
#Data visualization using matplotlib
plt.figure(figsize=(8,6))
plt.hist(cleaned_data['Age'],bins=6,color='red',edgecolor='black',
alpha=0.5)
plt.title('Histogram of Age')
plt.xlabel('Age')
plt.ylabel('Frequency')
plt.grid(True)
plt.show()