Interesting article how to use Pandas with Excel sheets

In summary, the conversation discusses an article about using Pandas in Python to read and manipulate data from a multi-tab spreadsheet, as well as the potential limitations and challenges of this method. The article was shared on a Slack channel for an online course, and the conversation also raises questions about the possibility of pivoting data across multiple sheets.
  • #1
scottdave
Science Advisor
Homework Helper
Insights Author
Gold Member
2,006
984
I came across this article about using Pandas in Python to read in a multi-tab spreadsheet to Python, and work with the data then write back to an Excel spreadsheet:
https://towardsdatascience.com/seve...w-i-use-python-where-excel-fails-62061f86ef9c
I have not yet tried it, but it looks pretty cool. The link was posted on a Slack channel for an online course I'm taking through edX/Georgia Tech. (Introduction to Computing for Data Analysis). It is part of their MicroMasters program in Analytics.
 
  • Like
Likes Asymptotic and QuantumQuest
Technology news on Phys.org
  • #2
Yes, that's pretty cool. The steps are somewhat involved and you'd have to check to make sure something didn't get lost.

Also is there some limit as to how many rows can get pivoted in this way? I'm guessing the max cols of the spreadsheet program which is 16,384:

https://support.office.com/en-us/ar...d-limits-1672b34d-7043-467e-8e27-269d656771c3

Normally for the data we work with, we'd use MATLAB functions to transpose the matrix of data but I'm not sure how that would work in this case with mixed datatypes of strings and numbers.

I also wonder if you could pivot across sheets (ala 3D matrix of data) as it seems that its possible.
 
  • Like
Likes scottdave and QuantumQuest

FAQ: Interesting article how to use Pandas with Excel sheets

How does Pandas work with Excel sheets?

Pandas is a popular Python library that provides powerful data analysis tools. It has a built-in function called read_excel() that allows users to read and import data from Excel sheets into a pandas DataFrame, which is a two-dimensional data structure. This makes it easy to manipulate and analyze data from Excel sheets using pandas.

Can I use Pandas to write data to an Excel sheet?

Yes, pandas has a to_excel() function that allows users to export a pandas DataFrame to an Excel sheet. This function also allows for customization of the output, such as specifying the sheet name and formatting options.

What are some common data manipulations that can be done with Pandas and Excel?

Pandas provides a wide range of data manipulation methods that can be applied to Excel sheets, such as filtering, sorting, grouping, and merging data. Users can also perform calculations and create new columns based on existing data using pandas.

Are there any limitations to using Pandas with Excel sheets?

While pandas is a powerful tool for working with Excel sheets, there are a few limitations to keep in mind. Firstly, pandas does not support macros, formulas, or other advanced Excel features. Additionally, the size of the Excel sheet may impact the performance of pandas, so it is recommended to split large sheets into smaller ones if possible.

Can I use Pandas with other file formats besides Excel?

Yes, pandas supports a wide range of file formats, including CSV, JSON, SQL databases, and more. It also has functions for reading and writing data to these file types, making it a versatile tool for data analysis and manipulation.

Back
Top