[英]How can I create a Class in Python3 using OOP to load and read data from an Excel file?
I am trying to create a Class called 'Settings' that can load an excel file, and create a dictionary called 'data' that returns the data from the individual sheets ('the key') of my excel file as a dataframe (the 'value'). I am trying to create a Class called 'Settings' that can load an excel file, and create a dictionary called 'data' that returns the data from the individual sheets ('the key') of my excel file as a dataframe (the '价值')。 I have laid out my proposed steps below but I would appreciate any guidance on how to construct my class using methods and instantiation.
我已经在下面列出了我建议的步骤,但我希望能提供有关如何使用方法和实例化构造我的 class 的任何指导。 Thank you
谢谢
import pandas as pd
class Settings():
#METHOD TO LOAD AN EXCEL FILE
def load(self):
self.load = load
#METHOD TO RETURN THE DATA FROM THE LOADED EXCEL INTO DICTIONARIES
def data(self):
self.data = data
#METHOD TO FILTER SOME OF THE DATA
def filter_data(self):
self.filter_data = filter_data
I am also unsure of how to build in the built-in Python operator pd.read_excel
into my class or one of the methods我也不确定如何将内置 Python 运算符
pd.read_excel
到我的 class 或其中一种方法中
You might want to look into openpyxl (reads Excel 2010 xlsx/xlsm) or xlrd (reads historical xls format) to read your Excel files with Python.您可能想查看openpyxl (读取 Excel 2010 xlsx/xlsm)或xlrd (读取历史 xls 格式)以使用 ZA7F5F35426B5674117323 读取 Excel 文件。 There are more alternatives out there, check www.python-excel.org .
还有更多选择,请查看www.python-excel.org 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.