w3resource

Pandas SQL Query: Display all the records of REGIONS file


1. Display All Records of REGIONS File

Write a Pandas program to display all the records of REGIONS file.

REGION.csv

Sample Solution :

Python Code :

import pandas as pd
employees = pd.read_csv(r"EMPLOYEES.csv")
departments = pd.read_csv(r"DEPARTMENTS.csv")
job_history = pd.read_csv(r"JOB_HISTORY.csv")
jobs = pd.read_csv(r"JOBS.csv")
countries = pd.read_csv(r"COUNTRIES.csv")
regions = pd.read_csv(r"REGIONS.csv")
locations = pd.read_csv(r"LOCATIONS.csv")
print("All the records from regions file:")
print(regions)

Sample Output:

All the records from regions file:
   REGION_ID             REGION_NAME
0          1                  Europe
1          2                Americas
2          3                    Asia
3          4  Middle East and Africa

Equivalent SQL Syntax:

SELECT * FROM REGIONS;

Click to view the table contain:

Employees Table

Departments Table

Countries Table

Job_History Table

Jobs Table

Locations Table

Regions Table


For more Practice: Solve these Related Problems:

  • Write a Pandas program to load the REGIONS.csv file using a custom delimiter and display the entire DataFrame.
  • Write a Pandas program to load REGIONS.csv in chunks and concatenate the chunks to display all records.
  • Write a Pandas program to load REGIONS.csv, sort the records by region name, and display the sorted DataFrame.
  • Write a Pandas program to load REGIONS.csv and filter out records where the region id is not numeric before displaying all records.

Go to:


Previous: Python Pandas HR database Exercises Home.
Next: Write a Pandas program to display all the location id from locations file.

Python Code Editor:

Structure of HR database :

HR database

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.