Skip to main content

Command Palette

Search for a command to run...

Exploring Data Input/Output in Pandas πŸ“₯πŸ“€

Published
β€’2 min read
Exploring Data Input/Output in Pandas πŸ“₯πŸ“€
P

πŸ‘‹ Hello! I'm passionate about DevOps and have over 1+ years of experience in the field. I'm proficient in a variety of cutting-edge technologies and always motivated to expand my knowledge and skills. Let's connect and grow together!

SKILLS:

πŸ”Ή Languages & Runtimes: Python, Shell Scripting, HCL, YAML πŸ”Ή Cloud Technologies: AWS, Microsoft Azure, GCP πŸ”Ή Infrastructure Tools: Docker, Terraform, AWS CloudFormation πŸ”Ή Other Tools: Linux, Git and GitHub Actions, Jenkins, Jira, GitLab (beginner), Docker, AWS DevOps πŸ”Ή Web Development: HTML, CSS, Bootstrap, Python, SQL

Job & Responsibilities:

πŸš€ Improved development efficiency by implementing CI/CD pipelines, resulting in a 30% reduction in deployment time on the test server. πŸ”’ Strengthened deployment and testing reliability by utilizing Docker containers and optimizing Dockerfile, reducing development issues on the test server by 20%. βš™οΈ Automated S3 bucket log creation with Shell scripting, eliminating 100% of manual search and saving 2 hours per week. πŸ“… Scheduled EC2 instance start/stop using Lambda functions and Event Bridge, leading to a 25% decrease in infrastructure costs. πŸ”§ Utilized AWS, Linux, Python, Docker, Shell scripting, Terraform, Jenkins Pipelines, and automation to streamline workflows and improve overall system performance.

I'm very detail-oriented and possess strong written and verbal communication skills. As a high performer with a possibility mindset, I strive to solve problems using efficient approaches.

Let's Connect & Grow:

If you find my profile suitable for the role you are searching for, please feel free to reach out to me at sumanprasad9766@gmail.com.

Introduction to Data Input/Output 🌐

Data Input/Output (I/O) in Pandas refers to the process of reading and writing data to various file formats. This capability is crucial for working with real-world datasets stored in different sources. Pandas simplifies these operations, allowing seamless interaction with popular file formats like CSV, Excel, SQL, and more.

Reading and Writing Data πŸ“–πŸ“

Pandas provides a set of functions for reading data from different sources and writing data to various file formats. Let's explore how to perform these operations:

Reading Data πŸ“Š

Use Case: Reading from a CSV file

# Example
import pandas as pd

# Read data from a CSV file
df = pd.read_csv('your_data.csv')

# Display the DataFrame
print(df)

Use Case: Reading from an Excel file

# Example
import pandas as pd

# Read data from an Excel file
df = pd.read_excel('your_data.xlsx', sheet_name='Sheet1')

# Display the DataFrame
print(df)

Writing Data πŸ“

Use Case: Writing to a CSV file

# Example
import pandas as pd

# Create a DataFrame
data = {'Name': ['Alice', 'Bob', 'Charlie'],
        'Age': [25, 30, 35]}
df = pd.DataFrame(data)

# Write DataFrame to a CSV file
df.to_csv('output_data.csv', index=False)

Use Case: Writing to an Excel file

# Example
import pandas as pd

# Create a DataFrame
data = {'Name': ['Alice', 'Bob', 'Charlie'],
        'Age': [25, 30, 35]}
df = pd.DataFrame(data)

# Write DataFrame to an Excel file
df.to_excel('output_data.xlsx', sheet_name='Sheet1', index=False)

Supported File Formats πŸ“„

Pandas supports a variety of file formats for data I/O. Some of the commonly used formats include:

  • CSV (Comma-Separated Values): Ideal for tabular data storage.

  • Excel: Perfect for spreadsheet-style data with multiple sheets.

  • SQL: Enables reading and writing data directly to and from databases.

Use Case: Reading from a SQL Database

# Example
import pandas as pd
from sqlalchemy import create_engine

# Create a SQLite database engine
engine = create_engine('sqlite:///your_database.db')

# Read data from a SQL table
df = pd.read_sql_table('your_table', con=engine)

# Display the DataFrame
print(df)

Use Case: Writing to a SQL Database

# Example
import pandas as pd
from sqlalchemy import create_engine

# Create a SQLite database engine
engine = create_engine('sqlite:///your_database.db')

# Write DataFrame to a SQL table
df.to_sql('your_table', con=engine, index=False, if_exists='replace')

Pandas' data I/O capabilities make it a versatile tool for handling data stored in different formats and locations. Whether you're reading from a CSV file, Excel spreadsheet, or a SQL database, Pandas simplifies the process, allowing you to focus on extracting insights from your data. πŸš€

More from this blog

D

DeployToCloud

405 posts

πŸ‘‹ Welcome to my Hashnode blog! I'm a DevOps Engineer with 2+ years of experience. Join ~5k followers and explore 320+ blogs on Python, AWS, Docker, Jenkins, Linux, and more. Let's connect & grow πŸš€