0% found this document useful (0 votes)
79 views6 pages

Major Terror Attacks in India Analysis

The document contains code to analyze terrorism data from a CSV file and summarize key details. It finds that Srinagar had the most attacks (n) in Jammu and Kashmir, India, carried out primarily by Lashkar-e-Taiba (g). It also reports that India had the most killed (killed) from terrorism in 2017 (year). Additionally, it determines that since May 26, 2014, Lashkar-e-Taiba was responsible for the majority of attacks (attack) in India.

Uploaded by

VamsiRevuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views6 pages

Major Terror Attacks in India Analysis

The document contains code to analyze terrorism data from a CSV file and summarize key details. It finds that Srinagar had the most attacks (n) in Jammu and Kashmir, India, carried out primarily by Lashkar-e-Taiba (g). It also reports that India had the most killed (killed) from terrorism in 2017 (year). Additionally, it determines that since May 26, 2014, Lashkar-e-Taiba was responsible for the majority of attacks (attack) in India.

Uploaded by

VamsiRevuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Terror casualty attack

## Open and read data file as specified in the question

## Print the required output in given format

## Open and read data file as specified in the question

## Print the required output in given format

import numpy as np

import csv

file=open("terrorismData.csv")

data=csv.DictReader(file,skipinitialspace=True)

d={}

for row in data:

if row["Country"]=="India":

c=row["City"]

k=row["Killed"]

w=row["Wounded"]

if(k==""):

k='0.0'

if(w==''):

w='0.0'

if c in d:

d[c]=d[c]+float(k)+float(w)

else:

d[c]=float(k)+float(w)

l=list(d.values())

l.sort(reverse=True)

for i in range(6):
for w in d:

if d[w]==l[i]:

if(w!='Unknown'):

print(w,' ',int(l[i]))

Pandas

Attack city

## Open and read data file as specified in the question

## Print the required output in given format

import pandas as pd

import csv

df=pd.read_csv("terrorismData.csv")

s=df[df.State=="Jammu and Kashmir"]

n=s.City.value_counts().max()

c=s.City.value_counts().argmax()

g=df[df.City==c]

g=g[g.Group!="Unknown"]

g=g.Group.value_counts().argmax()

print(c,n,g)
Terror attack

## Open and read data file as specified in the question

## Print the required output in given format

import pandas as pd

import numpy as np

import csv

t=pd.read_csv("terrorismData.csv")

df=t.copy()

country=df.Country.describe()['top']

df=df[df.Country==country]

killed=df.Year.describe()['count']

year=df["Year"].value_counts().argmax()

print(country,int(killed),year)

Terror govt

## Open and read data file as specified in the question

## Print the required output in given format

import pandas as pd

df=pd.read_csv("terrorismData.csv")

con=df.Country=="India"

df1=df[(df.Country=="India")&( (df.Year>2014) | ( (df.Year==2014) & (df.Month>5) ) | ( (df.Year==2014)


& (df.Month==5) & (df.Day>=26) ) )]

attack=df1.count()[0]
group=df1.Group.value_counts().index[1]

print(attack,group)

plot cty_job

# Open and read data file as specified in the question

# Print the required output in given format

import csv

import matplotlib.pyplot as plt

with open("amazon_jobs_dataset.csv") as file:

data=csv.DictReader(file,skipinitialspace=True)

d={}

for row in data:

loc=row['location']

l=loc.split(", ")

country=l[0]

if(country=="IN"):

c=l[len(l)-1]

d[c]=d.get(c,0)+1

city=[]

post=[]

for i in d:

city.append(i)

post.append(d[i])

plt.pie(post,labels=city,autopct='%.2f%%')
plt.show()

sum=sum(post)

for i in d:

pct=((d[i])/(sum))*100

print(i,format(pct,'.2f'))

# Open and read data file as specified in the question

# Print the required output in given format

import csv

import matplotlib.pyplot as plt

with open("amazon_jobs_dataset.csv") as file:

data=csv.DictReader(file,skipinitialspace=True)

d={}

for row in data:

y=row['Posting_date']

y=y[-4:]

if 'Java' in row['BASIC QUALIFICATIONS'] or 'java' in row['BASIC QUALIFICATIONS']:

d[y]=d.get(y,0)+1

year=[]

post=[]

for i in sorted(d):

year.append(i)

post.append(d[i])

print(i,d[i])

plt.scatter(year,post)

plt.show()

You might also like