Excel reading on a Python image from line 5 and including the headers
source link: https://www.codesd.com/item/excel-reading-on-a-python-image-from-line-5-and-including-the-headers.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Excel reading on a Python image from line 5 and including the headers
how do I import excel data into a dataframe in python.
Basically the current excel workbook runs some vba on opening which refreshes a pivot table and does some other stuff.
Then I wish to import the results of the pivot table refresh into a dataframe in python for further analysis.
import xlrd
wb = xlrd.open_workbook('C:\Users\cb\Machine_Learning\cMap_Joins.xlsm')
#sheetnames
print wb.sheet_names()
#number of sheets
print wb.nsheets
The refreshing and opening of the file works fine. But how do i select the data from the first sheet from say row 5 including header down to last record n.
You can use pandas' ExcelFile parse
method to read Excel sheets, see io docs:
xls = pd.ExcelFile('C:\Users\cb\Machine_Learning\cMap_Joins.xlsm')
df = xls.parse('Sheet1', skiprows=4, index_col=None, na_values=['NA'])
skiprows
will ignore the first 4 rows (i.e. start at row 5), and several other options.
Related Articles
Read a text file from a folder and save the folder name if a particular string is found in the text file - Python
I want to randomly select an image from a database and view it on an Aspx page
Viewing an image from a local folder using the Adaptive Grid view
Android: Download images from their path and view them in gridview
How to recover the image from mysql db and display it in & lt; td & gt; and & lt; img & gt; tag in HTML?
How to search for a string in Python by removing line breaks but returns the exact line where the string was found?
CSS add a line before and after the image
How can we shoot images from a website and display in our app using iphone sdk?
Is it possible to launch a web browser from my application and return the clicked URL?
call the same python script with variable arguments and analyze the arguments
How do I comment (#) 6 lines before and after the paired pattern in sed
Iterate from XML data and update the table
download files from external URLs, and forward the file to the user directly, without saving it to my server.
create a python dictionary from a list and a line separated by commas
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK