├── Figure_1.png ├── worldbank.xls ├── age distribution.png ├── population distrbution.png ├── Screenshot 2024-05-22 105259.png └── DSm1.py /Figure_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rahat-karim/PRODIGY_TrackCode_DS_Task1/HEAD/Figure_1.png -------------------------------------------------------------------------------- /worldbank.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rahat-karim/PRODIGY_TrackCode_DS_Task1/HEAD/worldbank.xls -------------------------------------------------------------------------------- /age distribution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rahat-karim/PRODIGY_TrackCode_DS_Task1/HEAD/age distribution.png -------------------------------------------------------------------------------- /population distrbution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rahat-karim/PRODIGY_TrackCode_DS_Task1/HEAD/population distrbution.png -------------------------------------------------------------------------------- /Screenshot 2024-05-22 105259.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rahat-karim/PRODIGY_TrackCode_DS_Task1/HEAD/Screenshot 2024-05-22 105259.png -------------------------------------------------------------------------------- /DSm1.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import pandas as pd 3 | 4 | # Bar Chart (Country vs Population) 5 | # Load the data 6 | file_path = "E:/new folder D/prodigy tasks/DS1/worldbank.xls" 7 | data = pd.read_excel(file_path, sheet_name='Data', header=1, usecols=[2, 3, 4]) 8 | 9 | # Rename columns for clarity 10 | data.columns = ['Year', 'Country Name', 'Population'] 11 | 12 | # Drop rows with missing values 13 | data.dropna(subset=['Population'], inplace=True) 14 | 15 | # Sort the data by population 16 | data_sorted = data.sort_values(by='Population', ascending=False).head(10) 17 | 18 | # Plot bar chart 19 | plt.figure(figsize=(12, 8)) 20 | plt.bar(data_sorted['Country Name'], data_sorted['Population'], color='skyblue', edgecolor='black') 21 | plt.title('Top 10 Countries by Population') 22 | plt.xlabel('Country') 23 | plt.ylabel('Population') 24 | plt.xticks(rotation=45) 25 | plt.grid(True) 26 | plt.show() 27 | 28 | # Customizing the x and y labels 29 | # Load the data 30 | file_path = "E:/new folder D/prodigy tasks/DS1/worldbank.xls" 31 | data = pd.read_excel(file_path, sheet_name='Data', header=1, usecols=[2, 3, 4]) 32 | 33 | # Rename columns for clarity 34 | data.columns = ['Year', 'Country Name', 'Age'] # Assuming 'Age' is the correct column name 35 | 36 | # Drop rows with missing values 37 | data.dropna(subset=['Age'], inplace=True) 38 | 39 | # Plot histogram 40 | plt.figure(figsize=(10, 6)) 41 | plt.hist(data['Age'], bins=20, color='skyblue', edgecolor='black') 42 | plt.title('Distribution of Age') 43 | plt.xlabel('Age') 44 | plt.ylabel('Frequency') 45 | plt.grid(True) 46 | plt.show() 47 | 48 | # Histogram (Population Distribution) 49 | # Load the data 50 | file_path = "E:/new folder D/prodigy tasks/DS1/worldbank.xls" 51 | data = pd.read_excel(file_path, sheet_name='Data', header=1, usecols=[2, 3, 4]) 52 | 53 | # Rename columns for clarity 54 | data.columns = ['Year', 'Country Name', 'Population'] 55 | 56 | # Drop rows with missing values 57 | data.dropna(subset=['Population'], inplace=True) 58 | 59 | # Plot histogram 60 | plt.figure(figsize=(10, 6)) 61 | plt.hist(data['Population'], bins=20, color='skyblue', edgecolor='black') 62 | plt.title('Distribution of Population') 63 | plt.xlabel('Population') 64 | plt.ylabel('Frequency') 65 | plt.grid(True) 66 | plt.show() --------------------------------------------------------------------------------