1. GRAPH OF EACH COUNTRY’S NO.
OF SATELLITES VS YEAR (WITH O/P OF MAX AND MIN SATELLITES LAUNCHED OVERALL W/ YEAR)
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("C:\\Users\\HP\\Downloads\\USA.csv")
df2 = pd.read_csv("C:\\Users\\HP\\Downloads\\IndianSatellites_SS1 - Sheet1 (2).csv")
df3 = pd.read_csv("C:\\Users\\HP\\Downloads\\Russia.csv")
print('To view year-wise graph of countries:')
a=int(input('USA=1,India=2,Russia=3: '))
if a==1:
year_counts = df.groupby('launch year')['launch year'].count()
plt.figure(figsize=(10, 6))
plt.bar(year_counts.index, year_counts.values)
plt.xlabel('Year')
plt.ylabel('Number of Satellites')
plt.title('Number of USA Satellites Launched Each Year')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()
min_year = year_counts.idxmin()
max_year = year_counts.idxmax()
print('max satellites launched in year = ', year_counts.max())
print('year = ', min_year)
print('min satellites launched in year = ', year_counts.min())
print('year = ', max_year)
print(‘Earliest Satellite launched in:’, year_counts.index.min())
elif a==2:
year_counts = df2.groupby('Year')['Year'].count()
plt.figure(figsize=(10, 6))
plt.bar(year_counts.index, year_counts.values)
plt.xlabel('Year')
plt.ylabel('Number of Satellites')
plt.title('Number of Indian Satellites Launched Each Year')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()
min_year = year_counts.idxmin()
max_year = year_counts.idxmax()
print('max satellites launched in year = ', year_counts.max())
print('year = ', min_year)
print('min satellites launched in year = ', year_counts.min())
print('year = ', max_year)
print(‘Earliest Satellite launched in:’, year_counts.index.min())
elif a==3:
year_counts = df3.groupby('Year')['Year'].count()
plt.figure(figsize=(10, 6))
plt.bar(year_counts.index, year_counts.values)
plt.xlabel('Year')
plt.ylabel('Number of Satellites')
plt.title('Number of Russian Satellites Launched Each Year')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()
min_year = year_counts.idxmin()
max_year = year_counts.idxmax()
print('max satellites launched in year = ', year_counts.max())
print('year = ', min_year)
print('min satellites launched in year = ', year_counts.min())
print('year = ', max_year)
print(‘Earliest Satellite launched in:’, year_counts.index.min())
else:
print('Invalid input')
2. SUCCESS VS FAILURE GRAPH OF EACH COUNTRY:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("C:\\Users\\HP\\Downloads\\USA.csv")
df2 = pd.read_csv("C:\\Users\\HP\\Downloads\\IndianSatellites_SS1 - Sheet1 (2).csv")
df3 = pd.read_csv("C:\\Users\\HP\\Downloads\\Russia.csv")
print('To view graph of Success VS. Failure countries:')
a=int(input('USA=1,India=2,Russia=3: '))
if a==1:
sc1 = df['success or failure'].value_counts()['success ']
sc2= df['success or failure'].value_counts()['partial success']
og1 = df['success or failure'].value_counts()['En route']
og2 = df['success or failure'].value_counts()['Operational']
failure_count = df['success or failure'].value_counts()['failure']
success_count = sc1+sc2
ongoing_count = og1+og2
plt.figure(figsize=(8, 6))
plt.bar(['Success', 'Failure','Ongoing'], [success_count, failure_count,ongoing_count])
plt.xlabel('Launch Outcome')
plt.ylabel('Number of Satellites')
plt.title('Success and Failure of USA Satellite Launches')
plt.tight_layout()
plt.show()
elif a==2:
success_count = df2['Failure/Success'].value_counts()['Success']
failure_count = df2['Failure/Success'].value_counts()['Faliure']
plt.figure(figsize=(8, 6))
plt.bar(['Success', 'Faliure'], [success_count, failure_count])
plt.xlabel('Launch Outcome')
plt.ylabel('Number of Satellites')
plt.title('Success and Failure of Indian Satellite Launches')
plt.tight_layout()
plt.show()
elif a==3:
success_count = df3['Success or failure?'].value_counts()['success']
failure_count = df3['Success or failure?'].value_counts()['failure']
ongoing_count = df3['Success or failure?'].value_counts()['en route']
plt.figure(figsize=(8, 6))
plt.bar(['Success', 'Failure','Ongoing'], [success_count, failure_count,ongoing_count])
plt.xlabel('Launch Outcome')
plt.ylabel('Number of Satellites')
plt.title('Success and Failure of Russian Satellite Launches')
plt.tight_layout()
plt.show()
else:
print('Invalid Input')
3. DF of satellite launched in a particular year for all countries:
import pandas as pd
file1 = pd.read_csv("C:\\Users\\HP\\Downloads\\USA.csv")
file2 = pd.read_csv("C:\\Users\\HP\\Downloads\\IndianSatellites_SS1 - Sheet1
(2).csv")
file3 = pd.read_csv("C:\\Users\\HP\\Downloads\\Russia.csv")
# Function to filter data by year
def filter_data_by_year(Year):
filtered_data1 = file1[file1['launch year'] == Year]
filtered_data2 = file2[file2['Year'] == Year]
filtered_data3 = file3[file3['Year'] == Year]
return filtered_data1, filtered_data2, filtered_data3
# User input for the year with validation
while True:
try:
user_year = int(input("Enter the year you want to filter data for
(1960-2024): "))
if 1960 <= user_year <= 2024:
break
else:
print("Please enter a year between 1960 and 2024.")
except ValueError:
print("Invalid input. Please enter a valid year.")
# Get the filtered data
data1, data2, data3 = filter_data_by_year(user_year)
print(f"\nFiltered data for the year {user_year} from file1 (USA):")
print(data1)
print(f"\nFiltered data for the year {user_year} from file2 (India):")
print(data2)
print(f"\nFiltered data for the year {user_year} from file3 (Russia):")
print(data3)
4. DF of sum of all satellites with years (sum):
import pandas as pd
all_counts = pd.concat([year_counts1, year_counts2, year_counts3], axis=1)
all_counts.columns = ['df1_counts', 'df2_counts', 'df3_counts']
# Group by index (year) and sum across columns
total_counts = all_counts.groupby(all_counts.index).sum()
total_counts['total'] = total_counts['df1_counts'] + total_counts['df2_counts'] +
total_counts['df3_counts']
sum=total_counts['total']
print(sum)
5. Graph of year vs. no of satellites launched in total:
import pandas as pd
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 6))
plt.bar(sum.index, sum.values)
plt.xlabel('Year')
plt.ylabel('Number of Satellites')
plt.title('Total Number of Satellites Launched Each Year')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()
min_year = sum.idxmin()
max_year = sum.idxmax()
print('max satellites = ', sum.max())
print('year = ', min_year)
print('min satellites = ', sum.min())
print('year = ', max_year)
print('Earliest satellite was launched in: ', sum.index.min())