SlideShare a Scribd company logo
JSON
• The full form of JSON is JavaScript Object Notation.
• It means that a script (executable) file which is made of text in a
programming language, is used to store and transfer the data.
• Python supports JSON through a built-in package called JSON.To use this
feature, we import the JSON package in Python script
• JSON (JavaScript Object Notation) is a lightweight, text-based data format
used for data exchange and storage.
• It's commonly used in web applications, APIs, and configuration files due to
its simplicity and human-readability.
• Python has a built-in json module that provides tools for working with JSON
data.
Key Features of JSON:
• Key-value pairs: Data is organized into key-value pairs, similar to Python dictionaries.
• Data types: Supports basic data types like strings, numbers, booleans, lists (arrays), and
nested JSON objects.
• Text-based: JSON is a plain text format, making it easy to read and transmit.
• Language-independent: It is widely supported across different programming languages.
• The json.load() function parses the JSON data from a file and returns it as a Python
dictionary or list.Writing to a JSON file.
• The json.dump() function converts a Python object into JSON format and writes it to a file.
The indent parameter is optional but makes the output more readable. Encoding Python
objects to JSON strings.
Write()
import json
data = {'name': 'John', 'age': 30}
with open('output.json', 'w') as f:
json.dump(data, f, indent=4)
Read()
with open('data.json', 'r') as f:
data = json.load(f)
data = {'name': 'John', 'age': 30}
json_string = json.dumps(data)
The json.dumps() function converts a Python object into a JSON string. Decoding JSON
strings to Python objects.
json_string = '{"name": "John", "age": 30}'
data = json.loads(json_string)
The json.loads() function parses a JSON string and returns it as a Python object.
import json
data = {
"name":“RK",
"place":“Hyd",
"skills": [
“Web",
"Machine Learning",
“AI"
],
"email":“rkreddybijjam@gmail.com",
"projects": [
"Python Data Mining",
"Python Data Science"
]
}
with open( "data_file.json" , "w" ) as write:
json.dump( data , write )
{
"emp_details":[
{
"name":“Ramya",
"designation": "programmer",
"age": "34",
"salary": "54000"
},
{
"name":“Ravi",
"designation": "Trainee",
"age": "24",
"salary": "40000"
}
]
}
# Python program to read
# json file
import json
# Opening JSON file
f = open('data.json’,)
# returns JSON object as
data = json.load(f)
# Iterating through the json
# list
for i in data['emp_details']:
print(i)
# Closing file
f.close()
json.loads() Method
• If we have a JSON string, we can parse it by using the json.loads() method.
• json.loads() does not take the file path, but the file contents as a string, to read the content of a JSON file
we can use fileobject.read() to convert the file into a string and pass it with json.loads().
• This method returns the content of the file.
• Syntax:
• json.loads(S)
• Parameter: it takes a string, bytes, or byte array instance which contains the JSON document as a
parameter (S).
• Return Type: It returns the Python object.
json.dump() in Python
import json
# python object(dictionary) to be dumped
dict1 ={
"emp1": {
"name": "Lisa",
"designation": "programmer",
"age": "34",
"salary": "54000"
},
"emp2": {
"name": "Elis",
"designation": "Trainee",
"age": "24",
"salary": "40000"
},
}
# the json file where the output must be stored
out_file = open("myfile.json", "w")
json.dump(dict1, out_file, indent = 6)
out_file.close()
import json
person = '{"name": "Bob", "languages": ["English", "French"]}'
person_dict = json.loads(person)
# Output: {'name': 'Bob', 'languages': ['English', 'French']}
print( person_dict)
# Output: ['English', 'French']
print(person_dict['languages'])
Python Convert to JSON string
You can convert a dictionary to JSON string using json.dumps() method.
import json
person_dict = {'name': 'Bob',
'age': 12,
'children': None
}
person_json = json.dumps(person_dict)
# Output: {"name": "Bob", "age": 12, "children": null}
print(person_json)
USING XML WITH PYTHON
• Extensible Mark-up Language is a simple and flexible text format that is used to exchange
different data on the web
• It is a universal format for data on the web
• Why we use XML?
• Reuse: Contents are separated from presentation and we can reuse
• Portability: It is an international platform independent, so developers can store their files safely
• Interchange: Interoperate and share data seamlessly
• Self-Describing:
• XML elements must have a closing tag
• Xml tags are case sensitive
• All XML elements must be properly nested
• All XML documents must have a root elements
• Attribute values must always be quoted
XML
<?xml version="1.0"?>
<employee>
<name>John Doe</name>
<age>35</age>
<job>
<title>Software Engineer</title>
<department>IT</department>
<years_of_experience>10</years_of_experience>
</job>
<address>
<street>123 Main St.</street>
<city>San Francisco</city>
<state>CA</state>
<zip>94102</zip>
</address>
</employee>
In this XML, we have used the same data shown in the JSON file.
You can observe that the elements in the XML files are stored using tags.
HERE IS AN EXAMPLE OF A SIMPLE JSON OBJECT:
{
"employee": {
"name": "John Doe",
"age": 35,
"job": {
"title": "Software Engineer",
"department": "IT",
"years_of_experience": 10
},
"address": {
"street": "123 Main St.",
"city": "San Francisco",
"state": "CA",
"zip": 94102
}
}
}
This JSON file contains details of an employee.You can observe that the data is stored as key-value pairs.
CONVERT JSON STRING TO XML STRING IN PYTHON
• To convert a JSON string to an XML string, we will first convert the json string to a python
dictionary.
• For this, we will use the loads() method defined in the json module.
• The loads() module takes the json string as its input argument and returns the dictionary.
• Next, we will convert the python dictionary to XML using the unparse() method defined in the
xmltodict module.
• The unparse() method takes the python dictionary as its input argument and returns an XML
string.
import json
import xmltodict
json_string="""{"employee": {"name": "John Doe", "age": "35", "job": {"title": "Software
Engineer", "department": "IT", "years_of_experience": "10"},"address": {"street": "123 Main
St.", "city": "San Francisco", "state": "CA", "zip": "94102"}}}
"""
print("The JSON string is:")
print(json_string)
python_dict=json.loads(json_string)
xml_string=xmltodict.unparse(python_dict)
print("The XML string is:")
print(xml_string)
OUT PUT Will be in XML And JSON
JSON STRING TO XML FILE IN PYTHON
• Instead of creating a string, we can also convert a JSON string to an XML file in python. For this, we will use the following
steps.
• first, we will convert the JSON string to a python dictionary using the loads() method defined in the json module.
• Next, we will open an empty XML file using the open() function.
• The open() function takes the file name as its first input argument and the literal “w” as its second input argument.
• After execution, it returns a file pointer.
• Once we get the file pointer, we will save the python dictionary to an XML file using the unparse() method defined in the
xmltodict module.
• The unparse() method takes the dictionary as its first argument and the file pointer as the argument to the output parameter.
• After execution, it writes the XML file to the storage.
• Finally, we will close the XML file using the close() method.
import json
import xmltodict
json_string="""{"employee": {"name": "John Doe", "age": "35", "job": {"title": "Software
Engineer", "department": "IT", "years_of_experience": "10"}, "address": {"street": "123 Main
St.", "city": "San Francisco", "state": "CA", "zip": "94102"}}}
"""
python_dict=json.loads(json_string)
file=open("person.xml","w")
xmltodict.unparse(python_dict,output=file)
file.close()
CONVERT JSON FILE TO XML STRING IN PYTHON
• To convert a JSON file to an XML string, we will first open the JSON file in read mode using
the open() function.
• The open() function takes the file name as its first input argument and the python literal “r”
as its second input argument. After execution, the open() function returns a file pointer.
import json
import xmltodict
file=open("person.json","r")
python_dict=json.load(file)
xml_string=xmltodict.unparse(python_dict)
print("The XML string is:")
print(xml_string)
JSON FILE TO XML FILE IN PYTHON
• First, we will open the JSON file in read mode using the open() function.
• For this, we will pass the filename as the first input argument and the literal “r” as the second
input argument to the open() function.
• The open() function returns a file pointer.
• Next, we will load the json file into a python dictionary using the load() method defined in
the json module.
• The load() method takes the file pointer as its input argument and returns a python
dictionary.
• Now, we will open an XML file using the open() function.
• Then, we will save the python dictionary to the XML file using the unparse() method defined
in the xmltodict module.
• Finally, we will close the XML file using the close() method.
import json
import xmltodict
file=open("person.json","r")
python_dict=json.load(file)
xml_file=open("person.xml","w")
xmltodict.unparse(python_dict,output=xml_file)
xml_file.close()
• After executing the above code, the content of the JSON file "person.json" will be
saved as XML in the "person.xml" file.
DATA SCIENCE INTRODUCTION
• Data science is about making sense of the vast amounts of data generated around us.
• Data science helps business uncovering patterns, trends, and insights hidden within
numbers, text, images, and more.
• It combines the power of mathematics, programming, and domain expertise to answer
questions, solve problems, and even make prediction about the future trend or requirements.
For example, from the huge raw data of a company, data science can help answer following
question:
• What do customer want?
• How can we improve our services?
• What will the upcoming trend in sales?
• How much stock they need for upcoming festival.
Where data science is being used?
• Data Science is being used in almost all major industry. Here are some examples:
• Predicting customer preferences for personalized recommendations.
• Detecting fraud in financial transactions.
• Forecasting sales and market trends.
• Enhancing healthcare with predictive diagnostics and personalized treatments.
• Identifying risks and opportunities in investments.
• Optimizing supply chains and inventory management.
Data Science Skills
All these data science actions are performed by a Data Scientists. Let's see essential skills required for
data scientists
• Programming Languages: Python, R, SQL.
• Mathematics: Linear Algebra, Statistics, Probability.
• Machine Learning: Supervised and unsupervised learning, deep learning basics.
• Data Manipulation: Pandas, NumPy, data wrangling techniques.
• Data Visualization: Matplotlib, Seaborn,Tableau, Power BI.
• Big Data Tools: Hadoop, Spark, Hive.
• Databases: SQL, NoSQL, data querying and management.
• Cloud Computing: AWS, Azure, Google Cloud.
• Version Control: Git, GitHub, GitLab.
• Domain Knowledge: Industry-specific expertise for problem-solving.
• Soft Skills: Communication, teamwork, and critical thinking.
• Data Science Life Cycle
• Data science is not a one-step process such that you will get to learn it in a short time and call
ourselves a Data Scientist.
• It's passes from many stages and every element is important.
• One should always follow the proper steps to reach the ladder.
• Every step has its value and it counts in your model.
How-Data-Science-Works.webp
DATA ANALYSIS SEQUENCE
• The data analysis sequence typically involves defining the business question, collecting and
cleaning data, analyzing the data, and then visualizing and communicating the findings.
• This process can be broken down into several key steps, often starting with understanding the
problem and culminating in actionable insights.
1. Define the Business Question/Objective:
• Start by clearly outlining what you want to achieve with the data analysis.What specific questions
are you trying to answer? This crucial first step will guide the rest of the process.
2. Collect and Store Data:
• Gather the necessary data from various sources.This might involve databases, spreadsheets,
APIs, or other platforms. Ensure the data is stored in a usable and organized format.
3. Clean and Prepare Data:
• This step involves handling missing values, correcting errors, and transforming the data into a
suitable format for analysis.
• Data cleaning is essential to ensure the accuracy and reliability of the results.
4. Analyze Data:
• Apply appropriate analytical techniques to extract meaningful insights.
• This could involve statistical analysis, data mining, machine learning, or other methods,
depending on the nature of the data and the questions being asked.
5.Visualize and Communicate Results:
• Present the findings in a clear and concise manner, using visualizations like charts and graphs
to make the information accessible and impactful.
• This step is vital for communicating the results to stakeholders and enabling data-driven
decision-making.
Data Acquisition Pipeline
Data Acquisition/Ingestion: This is the initial stage where raw data is gathered from various sources.
These sources can include databases, APIs, logs, IoT devices, and more.
2. Data Processing: Once ingested, the data often needs to be cleaned, transformed, and prepared for
analysis.
This may involve removing inconsistencies, handling missing values, aggregating data, or converting it
into a suitable format.
3. Data Storage: Processed data is then stored in a suitable repository.
This could be a data warehouse, a data lake, or a database, depending on the specific needs of the
organization.
4. Data Analysis: Analytical tools and algorithms are applied to the stored data to extract insights,
identify patterns, and generate reports or visualizations.
5. Data Visualization: The results of the analysis are often presented in a visual format, such as
dashboards or reports, to make the information accessible and understandable to stakeholders.
DATA ANALYSIS REPORT
What is a Data Analysis Report?
• A data analysis report is a comprehensive document that presents the findings, insights, and
interpretations derived from analyzing a dataset or datasets.
• It serves as a means of communicating the results of a data analysis process to stakeholders,
decision-makers, or other interested parties.
Why is Data Analysis Reporting Important?
• Data analysis reporting is critical for various reasons:
• Making decisions: Reports on data analysis provide decision-makers insightful information
that helps them make well-informed choices.These reports assist stakeholders in
understanding trends, patterns, and linkages that may guide strategic planning and decision-
making procedures by summarizing and analyzing data.
Performance Evaluation: Data analysis reports are used by organizations to assess how
well procedures, goods, or services are working.
Through the examination of pertinent metrics and key performance indicators (KPIs),
enterprises may pinpoint opportunities for improvement and maximize productivity.
Risk management: Within a company, data analysis reports may be used to detect possible
dangers, difficulties, or opportunities.
• Businesses may reduce risks and take advantage of new possibilities by examining past
data and predicting future patterns.
Communication and Transparency: By providing a concise and impartial summary of
study findings, data analysis reports promote communication and transparency within
enterprises.
With the help of these reports, stakeholders may successfully cooperate to solve problems
and accomplish goals by understanding complicated data insights.
Write a Data Analysis Report?
MapYour Report with an Outline
• Creating a well-structured outline is like drawing a roadmap for your report.
• It acts as a guide, to organize your thoughts and content logically.
• Begin by identifying the key sections of report, such as introduction, methodology, findings,
analysis, conclusions, and recommendations.
• Prioritize Key Performance Indicators (KPIs)
• In a data analysis report, it's crucial to prioritize the most relevant Key Performance
Indicators (KPIs) to avoid overwhelming your audience with unnecessary information. Start
by identifying the KPIs that directly impact your business objectives and overall
performance.
• These could include metrics like revenue growth, customer retention rates,
conversion rates, or website traffic.
Visualize Data with Impact
• Data visualization plays a pivotal role in conveying complex information in a clear and engaging
manner.
• When selecting visualization tools, consider the nature of the data and the story you want to tell.
Craft a Compelling Data Narrative
• Transforming your data into a compelling narrative is essential for engaging your audience and
highlighting key insights.
• Instead of presenting raw data, strive to tell a story that contextualizes the numbers and unveils
their significance.
Organize for Clarity
• Establishing a clear information hierarchy is essential for ensuring that your report is easy to
navigate and understand.
• Start by outlining the main points or sections of your report and consider the logical flow of
information.
Summarize Key Findings
• A concise summary at the beginning of your report serves as a roadmap for your
audience, providing them with a quick overview of the report's objectives and key
findings.
• However, it's important to write this summary after completing the report, as it requires a
comprehensive understanding of the data and analysis.
Best Practices forWriting Data Analysis Reports
• UnderstandYour Audience: It's important to know who will be reading the report before you start writing.
Make sure that the language, substance, and degree of technical information are appropriate for the
audience's expertise and interests.
• Clarity and Precision: Communicate your results in a clear, succinct manner by using appropriate
terminology. Steer clear of technical phrases and jargon that stakeholders who aren't technical may not
understand. Clarify terminology and ideas as needed to maintain understanding.
• Stay Objective: Don't include any prejudice or subjective interpretation while presenting your analysis and
results. Allow the data to speak for itself and back up your findings with facts.
• Focus on Key Insights: Summarize the most important conclusions and revelations that came from the
examination of the data. Sort material into categories according to the audience's relevancy and
significance.
• Provide Context: Put your analysis in perspective by outlining the importance of the data, how it relates to
the larger aims or objectives, and any relevant prior knowledge. Assist the reader in realizing the
significance of the analysis.
• UseVisualsWisely: Employ graphs, charts, and other visualizations to highlight important patterns,
correlations, and trends in the data. Select visual forms that make sense for the kind of data and the point
you're trying to make. Make sure the images are simple to understand, educational, and clear.

More Related Content

What's hot (20)

PPT
Introduction to Python
amiable_indian
 
PPT
File handling in c
David Livingston J
 
PPTX
Python Basics
Pooja B S
 
PPTX
django
Mohamed Essam
 
KEY
JSON-LD: JSON for Linked Data
Gregg Kellogg
 
PPT
javaScript.ppt
sentayehu
 
PDF
Python File Handling | File Operations in Python | Learn python programming |...
Edureka!
 
PPTX
HTML
chinesebilli
 
KEY
Introduction to Django
James Casey
 
PDF
Kotlin Coroutines in Practice @ KotlinConf 2018
Roman Elizarov
 
PPT
Exception handling and function in python
TMARAGATHAM
 
DOCX
Python Notes for mca i year students osmania university.docx
Ramakrishna Reddy Bijjam
 
PDF
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
PPTX
PHP slides
Farzad Wadia
 
PPT
Python ppt
Mohita Pandey
 
PPTX
Cascading style sheet
Michael Jhon
 
PPTX
Python
Sangita Panchal
 
PDF
glTF 2.0 Reference Guide
The Khronos Group Inc.
 
PPTX
Intro to JSON
Mark Daniel Dacer
 
PDF
Basic html
Nicha Jutasirivongse
 
Introduction to Python
amiable_indian
 
File handling in c
David Livingston J
 
Python Basics
Pooja B S
 
JSON-LD: JSON for Linked Data
Gregg Kellogg
 
javaScript.ppt
sentayehu
 
Python File Handling | File Operations in Python | Learn python programming |...
Edureka!
 
Introduction to Django
James Casey
 
Kotlin Coroutines in Practice @ KotlinConf 2018
Roman Elizarov
 
Exception handling and function in python
TMARAGATHAM
 
Python Notes for mca i year students osmania university.docx
Ramakrishna Reddy Bijjam
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
PHP slides
Farzad Wadia
 
Python ppt
Mohita Pandey
 
Cascading style sheet
Michael Jhon
 
glTF 2.0 Reference Guide
The Khronos Group Inc.
 
Intro to JSON
Mark Daniel Dacer
 

Similar to JSON, XML and Data Science introduction.pptx (20)

PPTX
CSV JSON and XML files in Python.pptx
Ramakrishna Reddy Bijjam
 
PPTX
JSON_FIles-Py (2).pptx
sravanicharugundla1
 
PPT
JSON(JavaScript Object Notation) Presentation transcript
SRI NISHITH
 
DOCX
Json1
thetechbuddyBlog
 
PPTX
Files.pptx
Govardhan Bhavani
 
PPTX
JSON,XML.pptx
Srinivas K
 
PDF
PyLecture3 -json-
Yoshiki Satotani
 
PPTX
Json
primeteacher32
 
PPT
GTR-Python-Using Web Services notesgtr.ppt
rajugt3
 
PDF
The Pandas Chapter 5(Important Questions).pdf
jagatpal4217
 
PPTX
JSON
Zara Tariq
 
PDF
What is Python JSON | Edureka
Edureka!
 
PDF
Dealing with JSON files in python with illustrations
Kiran Kumaraswamy
 
PPTX
module 2.pptx for full stack mobile development application on backend applic...
HemaSenthil5
 
PDF
JSON-Udemy.pdf
ssuser3d4c6e
 
PPTX
Pythonlearn-13-WebServices.pptx
nishant874609
 
CSV JSON and XML files in Python.pptx
Ramakrishna Reddy Bijjam
 
JSON_FIles-Py (2).pptx
sravanicharugundla1
 
JSON(JavaScript Object Notation) Presentation transcript
SRI NISHITH
 
Files.pptx
Govardhan Bhavani
 
JSON,XML.pptx
Srinivas K
 
PyLecture3 -json-
Yoshiki Satotani
 
GTR-Python-Using Web Services notesgtr.ppt
rajugt3
 
The Pandas Chapter 5(Important Questions).pdf
jagatpal4217
 
What is Python JSON | Edureka
Edureka!
 
Dealing with JSON files in python with illustrations
Kiran Kumaraswamy
 
module 2.pptx for full stack mobile development application on backend applic...
HemaSenthil5
 
JSON-Udemy.pdf
ssuser3d4c6e
 
Pythonlearn-13-WebServices.pptx
nishant874609
 
Ad

More from Ramakrishna Reddy Bijjam (20)

PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
DOCX
VBS control structures for if do whilw.docx
Ramakrishna Reddy Bijjam
 
DOCX
Builtinfunctions in vbscript and its types.docx
Ramakrishna Reddy Bijjam
 
DOCX
VBScript Functions procedures and arrays.docx
Ramakrishna Reddy Bijjam
 
DOCX
VBScript datatypes and control structures.docx
Ramakrishna Reddy Bijjam
 
PPTX
Numbers and global functions conversions .pptx
Ramakrishna Reddy Bijjam
 
DOCX
Structured Graphics in dhtml and active controls.docx
Ramakrishna Reddy Bijjam
 
DOCX
Filters and its types as wave shadow.docx
Ramakrishna Reddy Bijjam
 
PPTX
JavaScript Arrays and its types .pptx
Ramakrishna Reddy Bijjam
 
PPTX
JS Control Statements and Functions.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Code conversions binary to Gray vice versa.pptx
Ramakrishna Reddy Bijjam
 
PDF
FIXED and FLOATING-POINT-REPRESENTATION.pdf
Ramakrishna Reddy Bijjam
 
PPTX
Handling Missing Data for Data Analysis.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Data Frame Data structure in Python pandas.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Series data structure in Python Pandas.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Mongodatabase with Python for Students.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Arrays to arrays and pointers with arrays.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Python With MongoDB in advanced Python.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Pointers and single &multi dimentionalarrays.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Certinity Factor and Dempster-shafer theory .pptx
Ramakrishna Reddy Bijjam
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
VBS control structures for if do whilw.docx
Ramakrishna Reddy Bijjam
 
Builtinfunctions in vbscript and its types.docx
Ramakrishna Reddy Bijjam
 
VBScript Functions procedures and arrays.docx
Ramakrishna Reddy Bijjam
 
VBScript datatypes and control structures.docx
Ramakrishna Reddy Bijjam
 
Numbers and global functions conversions .pptx
Ramakrishna Reddy Bijjam
 
Structured Graphics in dhtml and active controls.docx
Ramakrishna Reddy Bijjam
 
Filters and its types as wave shadow.docx
Ramakrishna Reddy Bijjam
 
JavaScript Arrays and its types .pptx
Ramakrishna Reddy Bijjam
 
JS Control Statements and Functions.pptx
Ramakrishna Reddy Bijjam
 
Code conversions binary to Gray vice versa.pptx
Ramakrishna Reddy Bijjam
 
FIXED and FLOATING-POINT-REPRESENTATION.pdf
Ramakrishna Reddy Bijjam
 
Handling Missing Data for Data Analysis.pptx
Ramakrishna Reddy Bijjam
 
Data Frame Data structure in Python pandas.pptx
Ramakrishna Reddy Bijjam
 
Series data structure in Python Pandas.pptx
Ramakrishna Reddy Bijjam
 
Mongodatabase with Python for Students.pptx
Ramakrishna Reddy Bijjam
 
Arrays to arrays and pointers with arrays.pptx
Ramakrishna Reddy Bijjam
 
Python With MongoDB in advanced Python.pptx
Ramakrishna Reddy Bijjam
 
Pointers and single &multi dimentionalarrays.pptx
Ramakrishna Reddy Bijjam
 
Certinity Factor and Dempster-shafer theory .pptx
Ramakrishna Reddy Bijjam
 
Ad

Recently uploaded (20)

PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Dimensions of Societal Planning in Commonism
StefanMz
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 

JSON, XML and Data Science introduction.pptx

  • 1. JSON • The full form of JSON is JavaScript Object Notation. • It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. • Python supports JSON through a built-in package called JSON.To use this feature, we import the JSON package in Python script • JSON (JavaScript Object Notation) is a lightweight, text-based data format used for data exchange and storage. • It's commonly used in web applications, APIs, and configuration files due to its simplicity and human-readability. • Python has a built-in json module that provides tools for working with JSON data.
  • 2. Key Features of JSON: • Key-value pairs: Data is organized into key-value pairs, similar to Python dictionaries. • Data types: Supports basic data types like strings, numbers, booleans, lists (arrays), and nested JSON objects. • Text-based: JSON is a plain text format, making it easy to read and transmit. • Language-independent: It is widely supported across different programming languages. • The json.load() function parses the JSON data from a file and returns it as a Python dictionary or list.Writing to a JSON file. • The json.dump() function converts a Python object into JSON format and writes it to a file. The indent parameter is optional but makes the output more readable. Encoding Python objects to JSON strings.
  • 3. Write() import json data = {'name': 'John', 'age': 30} with open('output.json', 'w') as f: json.dump(data, f, indent=4) Read() with open('data.json', 'r') as f: data = json.load(f)
  • 4. data = {'name': 'John', 'age': 30} json_string = json.dumps(data) The json.dumps() function converts a Python object into a JSON string. Decoding JSON strings to Python objects. json_string = '{"name": "John", "age": 30}' data = json.loads(json_string) The json.loads() function parses a JSON string and returns it as a Python object.
  • 5. import json data = { "name":“RK", "place":“Hyd", "skills": [ “Web", "Machine Learning", “AI" ], "email":“[email protected]", "projects": [ "Python Data Mining", "Python Data Science" ] } with open( "data_file.json" , "w" ) as write: json.dump( data , write )
  • 6. { "emp_details":[ { "name":“Ramya", "designation": "programmer", "age": "34", "salary": "54000" }, { "name":“Ravi", "designation": "Trainee", "age": "24", "salary": "40000" } ] }
  • 7. # Python program to read # json file import json # Opening JSON file f = open('data.json’,) # returns JSON object as data = json.load(f) # Iterating through the json # list for i in data['emp_details']: print(i) # Closing file f.close()
  • 8. json.loads() Method • If we have a JSON string, we can parse it by using the json.loads() method. • json.loads() does not take the file path, but the file contents as a string, to read the content of a JSON file we can use fileobject.read() to convert the file into a string and pass it with json.loads(). • This method returns the content of the file. • Syntax: • json.loads(S) • Parameter: it takes a string, bytes, or byte array instance which contains the JSON document as a parameter (S). • Return Type: It returns the Python object.
  • 9. json.dump() in Python import json # python object(dictionary) to be dumped dict1 ={ "emp1": { "name": "Lisa", "designation": "programmer", "age": "34", "salary": "54000" }, "emp2": { "name": "Elis", "designation": "Trainee", "age": "24", "salary": "40000" }, } # the json file where the output must be stored out_file = open("myfile.json", "w") json.dump(dict1, out_file, indent = 6) out_file.close()
  • 10. import json person = '{"name": "Bob", "languages": ["English", "French"]}' person_dict = json.loads(person) # Output: {'name': 'Bob', 'languages': ['English', 'French']} print( person_dict) # Output: ['English', 'French'] print(person_dict['languages'])
  • 11. Python Convert to JSON string You can convert a dictionary to JSON string using json.dumps() method. import json person_dict = {'name': 'Bob', 'age': 12, 'children': None } person_json = json.dumps(person_dict) # Output: {"name": "Bob", "age": 12, "children": null} print(person_json)
  • 12. USING XML WITH PYTHON • Extensible Mark-up Language is a simple and flexible text format that is used to exchange different data on the web • It is a universal format for data on the web • Why we use XML? • Reuse: Contents are separated from presentation and we can reuse • Portability: It is an international platform independent, so developers can store their files safely • Interchange: Interoperate and share data seamlessly • Self-Describing:
  • 13. • XML elements must have a closing tag • Xml tags are case sensitive • All XML elements must be properly nested • All XML documents must have a root elements • Attribute values must always be quoted
  • 14. XML <?xml version="1.0"?> <employee> <name>John Doe</name> <age>35</age> <job> <title>Software Engineer</title> <department>IT</department> <years_of_experience>10</years_of_experience> </job> <address> <street>123 Main St.</street> <city>San Francisco</city> <state>CA</state> <zip>94102</zip> </address> </employee> In this XML, we have used the same data shown in the JSON file. You can observe that the elements in the XML files are stored using tags.
  • 15. HERE IS AN EXAMPLE OF A SIMPLE JSON OBJECT: { "employee": { "name": "John Doe", "age": 35, "job": { "title": "Software Engineer", "department": "IT", "years_of_experience": 10 }, "address": { "street": "123 Main St.", "city": "San Francisco", "state": "CA", "zip": 94102 } } } This JSON file contains details of an employee.You can observe that the data is stored as key-value pairs.
  • 16. CONVERT JSON STRING TO XML STRING IN PYTHON • To convert a JSON string to an XML string, we will first convert the json string to a python dictionary. • For this, we will use the loads() method defined in the json module. • The loads() module takes the json string as its input argument and returns the dictionary. • Next, we will convert the python dictionary to XML using the unparse() method defined in the xmltodict module. • The unparse() method takes the python dictionary as its input argument and returns an XML string.
  • 17. import json import xmltodict json_string="""{"employee": {"name": "John Doe", "age": "35", "job": {"title": "Software Engineer", "department": "IT", "years_of_experience": "10"},"address": {"street": "123 Main St.", "city": "San Francisco", "state": "CA", "zip": "94102"}}} """ print("The JSON string is:") print(json_string) python_dict=json.loads(json_string) xml_string=xmltodict.unparse(python_dict) print("The XML string is:") print(xml_string) OUT PUT Will be in XML And JSON
  • 18. JSON STRING TO XML FILE IN PYTHON • Instead of creating a string, we can also convert a JSON string to an XML file in python. For this, we will use the following steps. • first, we will convert the JSON string to a python dictionary using the loads() method defined in the json module. • Next, we will open an empty XML file using the open() function. • The open() function takes the file name as its first input argument and the literal “w” as its second input argument. • After execution, it returns a file pointer. • Once we get the file pointer, we will save the python dictionary to an XML file using the unparse() method defined in the xmltodict module. • The unparse() method takes the dictionary as its first argument and the file pointer as the argument to the output parameter. • After execution, it writes the XML file to the storage. • Finally, we will close the XML file using the close() method.
  • 19. import json import xmltodict json_string="""{"employee": {"name": "John Doe", "age": "35", "job": {"title": "Software Engineer", "department": "IT", "years_of_experience": "10"}, "address": {"street": "123 Main St.", "city": "San Francisco", "state": "CA", "zip": "94102"}}} """ python_dict=json.loads(json_string) file=open("person.xml","w") xmltodict.unparse(python_dict,output=file) file.close()
  • 20. CONVERT JSON FILE TO XML STRING IN PYTHON • To convert a JSON file to an XML string, we will first open the JSON file in read mode using the open() function. • The open() function takes the file name as its first input argument and the python literal “r” as its second input argument. After execution, the open() function returns a file pointer. import json import xmltodict file=open("person.json","r") python_dict=json.load(file) xml_string=xmltodict.unparse(python_dict) print("The XML string is:") print(xml_string)
  • 21. JSON FILE TO XML FILE IN PYTHON • First, we will open the JSON file in read mode using the open() function. • For this, we will pass the filename as the first input argument and the literal “r” as the second input argument to the open() function. • The open() function returns a file pointer. • Next, we will load the json file into a python dictionary using the load() method defined in the json module. • The load() method takes the file pointer as its input argument and returns a python dictionary. • Now, we will open an XML file using the open() function. • Then, we will save the python dictionary to the XML file using the unparse() method defined in the xmltodict module. • Finally, we will close the XML file using the close() method.
  • 22. import json import xmltodict file=open("person.json","r") python_dict=json.load(file) xml_file=open("person.xml","w") xmltodict.unparse(python_dict,output=xml_file) xml_file.close() • After executing the above code, the content of the JSON file "person.json" will be saved as XML in the "person.xml" file.
  • 23. DATA SCIENCE INTRODUCTION • Data science is about making sense of the vast amounts of data generated around us. • Data science helps business uncovering patterns, trends, and insights hidden within numbers, text, images, and more. • It combines the power of mathematics, programming, and domain expertise to answer questions, solve problems, and even make prediction about the future trend or requirements. For example, from the huge raw data of a company, data science can help answer following question: • What do customer want? • How can we improve our services? • What will the upcoming trend in sales? • How much stock they need for upcoming festival.
  • 24. Where data science is being used? • Data Science is being used in almost all major industry. Here are some examples: • Predicting customer preferences for personalized recommendations. • Detecting fraud in financial transactions. • Forecasting sales and market trends. • Enhancing healthcare with predictive diagnostics and personalized treatments. • Identifying risks and opportunities in investments. • Optimizing supply chains and inventory management.
  • 25. Data Science Skills All these data science actions are performed by a Data Scientists. Let's see essential skills required for data scientists • Programming Languages: Python, R, SQL. • Mathematics: Linear Algebra, Statistics, Probability. • Machine Learning: Supervised and unsupervised learning, deep learning basics. • Data Manipulation: Pandas, NumPy, data wrangling techniques. • Data Visualization: Matplotlib, Seaborn,Tableau, Power BI. • Big Data Tools: Hadoop, Spark, Hive. • Databases: SQL, NoSQL, data querying and management. • Cloud Computing: AWS, Azure, Google Cloud. • Version Control: Git, GitHub, GitLab. • Domain Knowledge: Industry-specific expertise for problem-solving. • Soft Skills: Communication, teamwork, and critical thinking.
  • 26. • Data Science Life Cycle • Data science is not a one-step process such that you will get to learn it in a short time and call ourselves a Data Scientist. • It's passes from many stages and every element is important. • One should always follow the proper steps to reach the ladder. • Every step has its value and it counts in your model. How-Data-Science-Works.webp
  • 27. DATA ANALYSIS SEQUENCE • The data analysis sequence typically involves defining the business question, collecting and cleaning data, analyzing the data, and then visualizing and communicating the findings. • This process can be broken down into several key steps, often starting with understanding the problem and culminating in actionable insights. 1. Define the Business Question/Objective: • Start by clearly outlining what you want to achieve with the data analysis.What specific questions are you trying to answer? This crucial first step will guide the rest of the process. 2. Collect and Store Data: • Gather the necessary data from various sources.This might involve databases, spreadsheets, APIs, or other platforms. Ensure the data is stored in a usable and organized format.
  • 28. 3. Clean and Prepare Data: • This step involves handling missing values, correcting errors, and transforming the data into a suitable format for analysis. • Data cleaning is essential to ensure the accuracy and reliability of the results. 4. Analyze Data: • Apply appropriate analytical techniques to extract meaningful insights. • This could involve statistical analysis, data mining, machine learning, or other methods, depending on the nature of the data and the questions being asked. 5.Visualize and Communicate Results: • Present the findings in a clear and concise manner, using visualizations like charts and graphs to make the information accessible and impactful. • This step is vital for communicating the results to stakeholders and enabling data-driven decision-making.
  • 30. Data Acquisition/Ingestion: This is the initial stage where raw data is gathered from various sources. These sources can include databases, APIs, logs, IoT devices, and more. 2. Data Processing: Once ingested, the data often needs to be cleaned, transformed, and prepared for analysis. This may involve removing inconsistencies, handling missing values, aggregating data, or converting it into a suitable format. 3. Data Storage: Processed data is then stored in a suitable repository. This could be a data warehouse, a data lake, or a database, depending on the specific needs of the organization. 4. Data Analysis: Analytical tools and algorithms are applied to the stored data to extract insights, identify patterns, and generate reports or visualizations. 5. Data Visualization: The results of the analysis are often presented in a visual format, such as dashboards or reports, to make the information accessible and understandable to stakeholders.
  • 31. DATA ANALYSIS REPORT What is a Data Analysis Report? • A data analysis report is a comprehensive document that presents the findings, insights, and interpretations derived from analyzing a dataset or datasets. • It serves as a means of communicating the results of a data analysis process to stakeholders, decision-makers, or other interested parties. Why is Data Analysis Reporting Important? • Data analysis reporting is critical for various reasons: • Making decisions: Reports on data analysis provide decision-makers insightful information that helps them make well-informed choices.These reports assist stakeholders in understanding trends, patterns, and linkages that may guide strategic planning and decision- making procedures by summarizing and analyzing data.
  • 32. Performance Evaluation: Data analysis reports are used by organizations to assess how well procedures, goods, or services are working. Through the examination of pertinent metrics and key performance indicators (KPIs), enterprises may pinpoint opportunities for improvement and maximize productivity. Risk management: Within a company, data analysis reports may be used to detect possible dangers, difficulties, or opportunities. • Businesses may reduce risks and take advantage of new possibilities by examining past data and predicting future patterns. Communication and Transparency: By providing a concise and impartial summary of study findings, data analysis reports promote communication and transparency within enterprises. With the help of these reports, stakeholders may successfully cooperate to solve problems and accomplish goals by understanding complicated data insights.
  • 33. Write a Data Analysis Report? MapYour Report with an Outline • Creating a well-structured outline is like drawing a roadmap for your report. • It acts as a guide, to organize your thoughts and content logically. • Begin by identifying the key sections of report, such as introduction, methodology, findings, analysis, conclusions, and recommendations. • Prioritize Key Performance Indicators (KPIs) • In a data analysis report, it's crucial to prioritize the most relevant Key Performance Indicators (KPIs) to avoid overwhelming your audience with unnecessary information. Start by identifying the KPIs that directly impact your business objectives and overall performance. • These could include metrics like revenue growth, customer retention rates, conversion rates, or website traffic.
  • 34. Visualize Data with Impact • Data visualization plays a pivotal role in conveying complex information in a clear and engaging manner. • When selecting visualization tools, consider the nature of the data and the story you want to tell. Craft a Compelling Data Narrative • Transforming your data into a compelling narrative is essential for engaging your audience and highlighting key insights. • Instead of presenting raw data, strive to tell a story that contextualizes the numbers and unveils their significance. Organize for Clarity • Establishing a clear information hierarchy is essential for ensuring that your report is easy to navigate and understand. • Start by outlining the main points or sections of your report and consider the logical flow of information.
  • 35. Summarize Key Findings • A concise summary at the beginning of your report serves as a roadmap for your audience, providing them with a quick overview of the report's objectives and key findings. • However, it's important to write this summary after completing the report, as it requires a comprehensive understanding of the data and analysis.
  • 36. Best Practices forWriting Data Analysis Reports • UnderstandYour Audience: It's important to know who will be reading the report before you start writing. Make sure that the language, substance, and degree of technical information are appropriate for the audience's expertise and interests. • Clarity and Precision: Communicate your results in a clear, succinct manner by using appropriate terminology. Steer clear of technical phrases and jargon that stakeholders who aren't technical may not understand. Clarify terminology and ideas as needed to maintain understanding. • Stay Objective: Don't include any prejudice or subjective interpretation while presenting your analysis and results. Allow the data to speak for itself and back up your findings with facts. • Focus on Key Insights: Summarize the most important conclusions and revelations that came from the examination of the data. Sort material into categories according to the audience's relevancy and significance. • Provide Context: Put your analysis in perspective by outlining the importance of the data, how it relates to the larger aims or objectives, and any relevant prior knowledge. Assist the reader in realizing the significance of the analysis. • UseVisualsWisely: Employ graphs, charts, and other visualizations to highlight important patterns, correlations, and trends in the data. Select visual forms that make sense for the kind of data and the point you're trying to make. Make sure the images are simple to understand, educational, and clear.