What is Pandas?
- Officially stands for Python Data Analysis Library.
- It is an open-source Python library.
- It is a tool used by data scientists to:
- read,
- write,
- manipulate, and
- analyze the data.
Why Pandas?
- It helps you explore and manipulate data efficiently.
- It helps you analyze large volumes of data with ease. When we say large volumes, it can be in millions of rows/records.
Why is Pandas so Popular?
- Easy to read and learn
- Extremely fast and powerful
- Integrates well with other visualization libraries
Importing Pandas
Anytime you want to use a library in Python, the first step is to make it accessible.
You can import/load Pandas in your notebook or any other Python IDE in two different ways:
1
import pandas
1
import pandas as pd
Just as we use the 'np' shorthand for NumPy, we will use the 'pd' shorthand for Pandas. It simply serves as an alias, and it is easier to use 'pd' instead of writing the full form ‘pandas’ while coding.
In this course, we will use .1
import pandas as pd
What is a CSV file?

- CSV files are usually created by programs that handle large amounts of data. They are a convenient way to export data from spreadsheets and databases and import or use them in other programs.
- CSV is a simple file format that stores tabular data, such as a spreadsheet or database.
- A CSV file stores tabular data (numbers and text) in plain text.
- Each line of the file is a data record/row.
- Each record consists of one or more fields, separated by commas.
- The use of the comma as a field separator is the source of the name for this file format.
What does a CSV file look like?

Working with CSV files in Python
- For working with CSV files in Python, there is an inbuilt module named csv.
- However, a common method for working with CSV files is using Pandas. It makes importing and analyzing data much easier.
- One crucial feature of Pandas is its ability to write and read Excel, CSV, and many other types of files.
Pandas read_csv
- Functions like the Pandas read_csv() method enable you to work with files effectively.
- The read_csv() function reads the CSV file into a DataFrame object.
- A CSV file is similar to a two-dimensional table, and the DataFrame object represents a two-dimensional tabular view.
- The most basic way to read a CSV file in Pandas:

- Now, let's understand how to provide the filename:

- One can do many other things through read_csv to change the returned object completely.
- For instance, one can read not just a local CSV file but even one from a URL, or choose what columns need to be imported so that we don't have to edit the array later.
- These modifications can be done by the various arguments it takes.
Pandas to_csv with example
- The easiest way to write DataFrames to CSV files is using the Pandas to_csv function.
- Syntax:

- If you want to export without the index, add index=False:

- Example:

