CSV files are the “comma-separated values”, these values are separated by commas, this file can be view like as excel file. In Python, Pandas is the most important library coming to data science. We need to deal with huge datasets while analyzing the data, which usually can get in CSV file format. Creating a pandas data-frame using CSV files can be achieved in multiple ways.
Note: Get the csv file used in the below examples from here.
Method #1: Using
read_csv() is an important pandas function to read csv files and do operations on it.
Method #2: Using
read_table() is another important pandas function to read csv files and create data frame from it.
Method #3: Using
csv module: One can directly import the csv files using csv module and then create a data frame using that csv file.
['TM195', '18', 'Male', '14', 'Single', '3', '4', '29562', '112']
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Creating a dataframe using Excel files
- Python program to read CSV without CSV module
- Working with csv files in Python
- Reading CSV files in Python
- Writing CSV files in Python
- Ways to import CSV files in Google Colab
- Reading and Writing CSV Files in Python
- Convert multiple JSON files to CSV Python
- Pandas - DataFrame to CSV file using tab separator
- Creating Files in HDFS using Python Snakebite
- Saving a Pandas Dataframe as a CSV
- How to read a CSV file to a Dataframe with custom delimiter in Pandas?
- How to export Pandas DataFrame to a CSV file?
- Export Pandas dataframe to a CSV file
- Creating a Pandas dataframe using list of tuples
- Creating Pandas dataframe using list of lists
- Creating a Pandas DataFrame
- Python | Creating a Pandas dataframe column based on a given condition
- Creating views on Pandas DataFrame
- Creating views on Pandas DataFrame | Set - 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.