SlideShare a Scribd company logo
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Python Development Example
Merge Pandas DataFrame
Johan Louwers – Chief Customer Architect @ Oracle
Version : Feb 2019
@johanlouwers
Johanlouwers.blogspot.com
Oracle Confidential – Internal/Restricted/Highly Restricted
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
2
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Python Development
with pandas and CX_Oracle
Slide-deck Intention :
• This presentation is intended to provide
a quick introduction example on how to
merge two DataFrames in Pandas
• This example is a part of a wider
workshop deck and shared as a stand-
alone example for ease of sharing.
• The code should only be used as an
educational example and is not
intended to be included in any real-
world application code.
3
Contact details :
Johan Louwers - Chief Customer Architect
@johanlouwers
Johan.louwers@oracle.com
github.com/louwersj
Johanlouwers.blogspot.com
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
A B C D
0 A0 B0 C0 D0
1 A1 B1 C1 D1
2 A2 B2 C2 D2
4
A B C D
0 A0 B0 C0 D0
1 A1 B1 C1 D1
2 A2 B2 C2 D2
A B C_x D_x C_y D_y
0 A0 B0 C0 D0 C0 D0
1 A1 B1 C1 D1 C1 D1
2 A2 B2 C2 D2 C2 D2
pd.read_csv
pd.read_csv
pd.merge
Python Development
Pandas – merge DataFrame
What do we want to achieve?
1) Load two sets of data from .csv files
2) “merge” them into a single dataframe
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 5
import pandas as pd
df0 = pd.read_csv('../../data/dataset_4.csv', delimiter=";",)
print ('show the content of the first file via dataframe df0')
print (df0.head())
df1 = pd.read_csv('../../data/dataset_5.csv', delimiter=";",)
print ('show the content of the second file via dataframe df1')
print (df1.head())
df2 = pd.merge(df0, df1, on=['Country Code','Country Name'])
print ('show the content of merged dataframes as a single dataframe')
print (df2.head())
Python Development
Pandas – merge DataFrame
Read first
CSV file
Read second
CSV file
Merge
DataFrames
Show me the code
1) Please note the 3 steps in the above code (two times read_csv() and one merge()
2) Find example at : https://github.com/louwersj/examples_machineLearning/blob/master/pandas/merging/pd_merge_example_1.py
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 6
Python Development
Pandas – merge DataFrame
Show me the output
1) Do note that the two “original” dataFrame objects contain each 63 columns
2) Do note that the “merged” DataFrame contains 124 columns and not 126 columns.
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 7
Oracle python pandas merge DataFrames
Ad

Recommended

Clustering
Clustering
Rashmi Bhat
 
Classification techniques in data mining
Classification techniques in data mining
Kamal Acharya
 
Latent Dirichlet Allocation
Latent Dirichlet Allocation
Sangwoo Mo
 
Multi media Data mining
Multi media Data mining
home
 
Principal Component Analysis
Principal Component Analysis
Ricardo Wendell Rodrigues da Silveira
 
CLUSTER ANALYSIS ALGORITHMS.pptx
CLUSTER ANALYSIS ALGORITHMS.pptx
ShwetapadmaBabu1
 
Lexical Analysis
Lexical Analysis
Nayemid4676
 
Machine Learning with Decision trees
Machine Learning with Decision trees
Knoldus Inc.
 
Unsupervised learning
Unsupervised learning
amalalhait
 
Introduction to Neural Networks
Introduction to Neural Networks
Databricks
 
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
JenishaR1
 
Reinforcement learning
Reinforcement learning
Chandra Meena
 
Principal component analysis
Principal component analysis
Partha Sarathi Kar
 
State space search
State space search
chauhankapil
 
Uniformed tree searching
Uniformed tree searching
Ayaelshiwi
 
AI3391 Artificial intelligence Session 28 Resolution.pptx
AI3391 Artificial intelligence Session 28 Resolution.pptx
Guru Nanak Technical Institutions
 
Borderline Smote
Borderline Smote
Trector Rancor
 
Generating function
Generating function
Kongunadu College of Engineering and Technology
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization
Sourabh Sahu
 
Data clustering
Data clustering
GARIMA SHAKYA
 
Unsupervised learning (clustering)
Unsupervised learning (clustering)
Pravinkumar Landge
 
12 pattern recognition
12 pattern recognition
Talal Khaliq
 
Specification-of-tokens
Specification-of-tokens
Dattatray Gandhmal
 
Hierarchical Clustering
Hierarchical Clustering
Carlos Castillo (ChaTo)
 
Hierarchical clustering.pptx
Hierarchical clustering.pptx
NTUConcepts1
 
Anomaly Detection @Twitter
Anomaly Detection @Twitter
Zhan Zhang
 
GAN in medical imaging
GAN in medical imaging
Cheng-Bin Jin
 
Principal Component Analysis and Clustering
Principal Component Analysis and Clustering
Usha Vijay
 
Importing Data Sets | Importing Data Sets | Importing Data Sets
Importing Data Sets | Importing Data Sets | Importing Data Sets
Ayxanhmdzad
 
import data from Oracle Database into Python Pandas Dataframe
import data from Oracle Database into Python Pandas Dataframe
Johan Louwers
 

More Related Content

What's hot (20)

Unsupervised learning
Unsupervised learning
amalalhait
 
Introduction to Neural Networks
Introduction to Neural Networks
Databricks
 
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
JenishaR1
 
Reinforcement learning
Reinforcement learning
Chandra Meena
 
Principal component analysis
Principal component analysis
Partha Sarathi Kar
 
State space search
State space search
chauhankapil
 
Uniformed tree searching
Uniformed tree searching
Ayaelshiwi
 
AI3391 Artificial intelligence Session 28 Resolution.pptx
AI3391 Artificial intelligence Session 28 Resolution.pptx
Guru Nanak Technical Institutions
 
Borderline Smote
Borderline Smote
Trector Rancor
 
Generating function
Generating function
Kongunadu College of Engineering and Technology
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization
Sourabh Sahu
 
Data clustering
Data clustering
GARIMA SHAKYA
 
Unsupervised learning (clustering)
Unsupervised learning (clustering)
Pravinkumar Landge
 
12 pattern recognition
12 pattern recognition
Talal Khaliq
 
Specification-of-tokens
Specification-of-tokens
Dattatray Gandhmal
 
Hierarchical Clustering
Hierarchical Clustering
Carlos Castillo (ChaTo)
 
Hierarchical clustering.pptx
Hierarchical clustering.pptx
NTUConcepts1
 
Anomaly Detection @Twitter
Anomaly Detection @Twitter
Zhan Zhang
 
GAN in medical imaging
GAN in medical imaging
Cheng-Bin Jin
 
Principal Component Analysis and Clustering
Principal Component Analysis and Clustering
Usha Vijay
 
Unsupervised learning
Unsupervised learning
amalalhait
 
Introduction to Neural Networks
Introduction to Neural Networks
Databricks
 
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
JenishaR1
 
Reinforcement learning
Reinforcement learning
Chandra Meena
 
State space search
State space search
chauhankapil
 
Uniformed tree searching
Uniformed tree searching
Ayaelshiwi
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization
Sourabh Sahu
 
Unsupervised learning (clustering)
Unsupervised learning (clustering)
Pravinkumar Landge
 
12 pattern recognition
12 pattern recognition
Talal Khaliq
 
Hierarchical clustering.pptx
Hierarchical clustering.pptx
NTUConcepts1
 
Anomaly Detection @Twitter
Anomaly Detection @Twitter
Zhan Zhang
 
GAN in medical imaging
GAN in medical imaging
Cheng-Bin Jin
 
Principal Component Analysis and Clustering
Principal Component Analysis and Clustering
Usha Vijay
 

Similar to Oracle python pandas merge DataFrames (20)

Importing Data Sets | Importing Data Sets | Importing Data Sets
Importing Data Sets | Importing Data Sets | Importing Data Sets
Ayxanhmdzad
 
import data from Oracle Database into Python Pandas Dataframe
import data from Oracle Database into Python Pandas Dataframe
Johan Louwers
 
series and dataframes from python is discussed
series and dataframes from python is discussed
vidhyapm2
 
pandas.pdf
pandas.pdf
AjeshSurejan2
 
pandas (1).pdf
pandas (1).pdf
AjeshSurejan2
 
Week2: Programming for Data Analysis
Week2: Programming for Data Analysis
Ferdin Joe John Joseph PhD
 
Group B - Pandas Pandas is a powerful Python library that provides high-perfo...
Group B - Pandas Pandas is a powerful Python library that provides high-perfo...
HarshitChauhan88
 
SciPy 2011 pandas lightning talk
SciPy 2011 pandas lightning talk
Wes McKinney
 
python-pandas-For-Data-Analysis-Manipulate.pptx
python-pandas-For-Data-Analysis-Manipulate.pptx
PLOKESH8
 
Lecture 3 intro2data
Lecture 3 intro2data
Johnson Ubah
 
Pandas csv
Pandas csv
Devashish Kumar
 
Pandas
Pandas
Dr. Chitra Dhawale
 
pandas directories on the python language.pptx
pandas directories on the python language.pptx
SumitMajukar
 
Handling Missing Data for Data Analysis.pptx
Handling Missing Data for Data Analysis.pptx
Ramakrishna Reddy Bijjam
 
Complete Introduction To Pandas Python.pptx
Complete Introduction To Pandas Python.pptx
ARUN R S
 
Pandas-(Ziad).pptx
Pandas-(Ziad).pptx
Sivam Chinna
 
dataframe_operations and various functions
dataframe_operations and various functions
JayanthiM19
 
Pandas in Python for Data Exploration .pdf
Pandas in Python for Data Exploration .pdf
sejalkadam21
 
Python Data Wrangling: Preparing for the Future
Python Data Wrangling: Preparing for the Future
Wes McKinney
 
Worksheet - python Pandas numerical py pdf
Worksheet - python Pandas numerical py pdf
udaywalnandini
 
Importing Data Sets | Importing Data Sets | Importing Data Sets
Importing Data Sets | Importing Data Sets | Importing Data Sets
Ayxanhmdzad
 
import data from Oracle Database into Python Pandas Dataframe
import data from Oracle Database into Python Pandas Dataframe
Johan Louwers
 
series and dataframes from python is discussed
series and dataframes from python is discussed
vidhyapm2
 
Group B - Pandas Pandas is a powerful Python library that provides high-perfo...
Group B - Pandas Pandas is a powerful Python library that provides high-perfo...
HarshitChauhan88
 
SciPy 2011 pandas lightning talk
SciPy 2011 pandas lightning talk
Wes McKinney
 
python-pandas-For-Data-Analysis-Manipulate.pptx
python-pandas-For-Data-Analysis-Manipulate.pptx
PLOKESH8
 
Lecture 3 intro2data
Lecture 3 intro2data
Johnson Ubah
 
pandas directories on the python language.pptx
pandas directories on the python language.pptx
SumitMajukar
 
Handling Missing Data for Data Analysis.pptx
Handling Missing Data for Data Analysis.pptx
Ramakrishna Reddy Bijjam
 
Complete Introduction To Pandas Python.pptx
Complete Introduction To Pandas Python.pptx
ARUN R S
 
Pandas-(Ziad).pptx
Pandas-(Ziad).pptx
Sivam Chinna
 
dataframe_operations and various functions
dataframe_operations and various functions
JayanthiM19
 
Pandas in Python for Data Exploration .pdf
Pandas in Python for Data Exploration .pdf
sejalkadam21
 
Python Data Wrangling: Preparing for the Future
Python Data Wrangling: Preparing for the Future
Wes McKinney
 
Worksheet - python Pandas numerical py pdf
Worksheet - python Pandas numerical py pdf
udaywalnandini
 
Ad

More from Johan Louwers (20)

Multi Domain REST API routing for Data Mesh based Data Products
Multi Domain REST API routing for Data Mesh based Data Products
Johan Louwers
 
TClab Dynamic Solar Panel Positioning Systems
TClab Dynamic Solar Panel Positioning Systems
Johan Louwers
 
Oracle Cloud With Azure DevOps Pipelines
Oracle Cloud With Azure DevOps Pipelines
Johan Louwers
 
Oracle Cloud native functions - create application from cli
Oracle Cloud native functions - create application from cli
Johan Louwers
 
Oracle Labs - research mission & project potfolio
Oracle Labs - research mission & project potfolio
Johan Louwers
 
Install Redis on Oracle Linux
Install Redis on Oracle Linux
Johan Louwers
 
Fn project quick installation guide
Fn project quick installation guide
Johan Louwers
 
Voice assistants for the insurance industry
Voice assistants for the insurance industry
Johan Louwers
 
Enterprise wide publish subscribe with Apache Kafka
Enterprise wide publish subscribe with Apache Kafka
Johan Louwers
 
Industry 4.0 and Oracle Cloud
Industry 4.0 and Oracle Cloud
Johan Louwers
 
Docker and microservices - moving from a monolith to microservices
Docker and microservices - moving from a monolith to microservices
Johan Louwers
 
Cloud native applications for banking
Cloud native applications for banking
Johan Louwers
 
Conversational retail
Conversational retail
Johan Louwers
 
Oracle Cloudday security
Oracle Cloudday security
Johan Louwers
 
Oracle Cloudday - the future of retail
Oracle Cloudday - the future of retail
Johan Louwers
 
Capgemini Oracle Cloud Access Security Broker
Capgemini Oracle Cloud Access Security Broker
Johan Louwers
 
Microservices in the oracle cloud
Microservices in the oracle cloud
Johan Louwers
 
Oracle cloud, private, public and hybrid
Oracle cloud, private, public and hybrid
Johan Louwers
 
RethinkDB on Oracle Linux
RethinkDB on Oracle Linux
Johan Louwers
 
Oracle Cloud Hybrid Storage Tiering
Oracle Cloud Hybrid Storage Tiering
Johan Louwers
 
Multi Domain REST API routing for Data Mesh based Data Products
Multi Domain REST API routing for Data Mesh based Data Products
Johan Louwers
 
TClab Dynamic Solar Panel Positioning Systems
TClab Dynamic Solar Panel Positioning Systems
Johan Louwers
 
Oracle Cloud With Azure DevOps Pipelines
Oracle Cloud With Azure DevOps Pipelines
Johan Louwers
 
Oracle Cloud native functions - create application from cli
Oracle Cloud native functions - create application from cli
Johan Louwers
 
Oracle Labs - research mission & project potfolio
Oracle Labs - research mission & project potfolio
Johan Louwers
 
Install Redis on Oracle Linux
Install Redis on Oracle Linux
Johan Louwers
 
Fn project quick installation guide
Fn project quick installation guide
Johan Louwers
 
Voice assistants for the insurance industry
Voice assistants for the insurance industry
Johan Louwers
 
Enterprise wide publish subscribe with Apache Kafka
Enterprise wide publish subscribe with Apache Kafka
Johan Louwers
 
Industry 4.0 and Oracle Cloud
Industry 4.0 and Oracle Cloud
Johan Louwers
 
Docker and microservices - moving from a monolith to microservices
Docker and microservices - moving from a monolith to microservices
Johan Louwers
 
Cloud native applications for banking
Cloud native applications for banking
Johan Louwers
 
Conversational retail
Conversational retail
Johan Louwers
 
Oracle Cloudday security
Oracle Cloudday security
Johan Louwers
 
Oracle Cloudday - the future of retail
Oracle Cloudday - the future of retail
Johan Louwers
 
Capgemini Oracle Cloud Access Security Broker
Capgemini Oracle Cloud Access Security Broker
Johan Louwers
 
Microservices in the oracle cloud
Microservices in the oracle cloud
Johan Louwers
 
Oracle cloud, private, public and hybrid
Oracle cloud, private, public and hybrid
Johan Louwers
 
RethinkDB on Oracle Linux
RethinkDB on Oracle Linux
Johan Louwers
 
Oracle Cloud Hybrid Storage Tiering
Oracle Cloud Hybrid Storage Tiering
Johan Louwers
 
Ad

Recently uploaded (20)

Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
Edge AI and Vision Alliance
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
Edge AI and Vision Alliance
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 

Oracle python pandas merge DataFrames

  • 1. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Python Development Example Merge Pandas DataFrame Johan Louwers – Chief Customer Architect @ Oracle Version : Feb 2019 @johanlouwers Johanlouwers.blogspot.com Oracle Confidential – Internal/Restricted/Highly Restricted
  • 2. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2
  • 3. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Python Development with pandas and CX_Oracle Slide-deck Intention : • This presentation is intended to provide a quick introduction example on how to merge two DataFrames in Pandas • This example is a part of a wider workshop deck and shared as a stand- alone example for ease of sharing. • The code should only be used as an educational example and is not intended to be included in any real- world application code. 3 Contact details : Johan Louwers - Chief Customer Architect @johanlouwers [email protected] github.com/louwersj Johanlouwers.blogspot.com
  • 4. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | A B C D 0 A0 B0 C0 D0 1 A1 B1 C1 D1 2 A2 B2 C2 D2 4 A B C D 0 A0 B0 C0 D0 1 A1 B1 C1 D1 2 A2 B2 C2 D2 A B C_x D_x C_y D_y 0 A0 B0 C0 D0 C0 D0 1 A1 B1 C1 D1 C1 D1 2 A2 B2 C2 D2 C2 D2 pd.read_csv pd.read_csv pd.merge Python Development Pandas – merge DataFrame What do we want to achieve? 1) Load two sets of data from .csv files 2) “merge” them into a single dataframe
  • 5. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 5 import pandas as pd df0 = pd.read_csv('../../data/dataset_4.csv', delimiter=";",) print ('show the content of the first file via dataframe df0') print (df0.head()) df1 = pd.read_csv('../../data/dataset_5.csv', delimiter=";",) print ('show the content of the second file via dataframe df1') print (df1.head()) df2 = pd.merge(df0, df1, on=['Country Code','Country Name']) print ('show the content of merged dataframes as a single dataframe') print (df2.head()) Python Development Pandas – merge DataFrame Read first CSV file Read second CSV file Merge DataFrames Show me the code 1) Please note the 3 steps in the above code (two times read_csv() and one merge() 2) Find example at : https://github.com/louwersj/examples_machineLearning/blob/master/pandas/merging/pd_merge_example_1.py
  • 6. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 6 Python Development Pandas – merge DataFrame Show me the output 1) Do note that the two “original” dataFrame objects contain each 63 columns 2) Do note that the “merged” DataFrame contains 124 columns and not 126 columns.
  • 7. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 7