Prerequisite: Regular Expressions in Python
In these articles, we will discuss how to extract Time data from an Excel file column using Pandas. Suppose our Excel file looks like below given image then we have to extract the Time from the Excel sheet column and store it into a new Dataframe column.
For viewing the Excel file Click Here.
- Import the required module.
- Import data from Excel file.
- Make an extra column for store extracted time.
- Set Index for searching for extracting column.
- Define the pattern of Time format (HH: MM: SS).
- Search Time and assigning to the respective column in Dataframe.
Let’s see Step-By-Step-Implementation:
Step 1: Import the required module and read data from Excel file.
Step 2: Make an extra column for storing Time data.
Step 3: Set Index for searching
Step 4: Defining the Regular expression (regex) for the time.
Regex for time HH/ MM/ SS format:
Step 5: Search Time and assigning to the respective column in Dataframe.
For searching the time using regex in a string we are using re.search() function of re library.
Note: Before running this program, make sure you have already installed xlrd library in your Python environment.
- How to extract Email column from Excel file and find out the type of mail using Pandas?
- How to extract date from Excel file using Pandas?
- How to import excel file and find a specific column using Pandas?
- Find the sum and maximum value of the two column in excel file using Pandas
- Python - Extract ith column values from jth column values
- Create a GUI to convert CSV file into excel file using Python
- Python | Plotting column charts in excel sheet with data tables using XlsxWriter module
- How to import an excel file into Python using Pandas?
- Extract date from a specified column of a given Pandas DataFrame using Regex
- Exporting a Pandas DataFrame to an Excel file
- Joining Excel Data from Multiple files using Python Pandas
- Python | Plotting column charts in excel sheet using XlsxWriter module
- Python | Plotting an Excel chart with pattern fills in column using XlsxWriter module
- How to Filter and save the data as new files in Excel with Python Pandas?
- Get column index from column name of a given Pandas DataFrame
- Create a Pandas DataFrame from a Numpy array and specify the index column and column headers
- Python | Test if number is valid Excel column
- Python | Writing to an excel file using openpyxl module
- Reading an excel file using Python
- Python | Arithmetic operations in excel file using openpyxl
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.