这是一个很棒的软件包,它可以帮助我们从googlesheets创建一个图形,并将其存储为图像

gsheet-image-generator的Python项目详细描述


GSHEET_图像发生器

此API的使用

一个很棒的包,可以帮助我们从Google工作表创建一个图形,并将它们存储为图像。 通过从工作表中选择两列(即x轴和y轴)绘制图形。


安装

pip install gsheet_image_generator

使用其 您想要访问电子表格。创建(或选择)项目并启用 Drive APISheets API(位于Google Apps API)。在

转到项目的Credentials,并创建New Credentials>;OAuth client ID>;类型为Other。在您的OAuth 2.0客户机ID列表中,单击Download JSON作为您刚刚创建的客户机ID。将文件另存为主目录(用户目录)中的client_secrets.json。在本例中,另一个名为storage.json的文件将在成功授权缓存OAuth数据后创建。 {3}你的客户机会用你的Google浏览器来访问这个文件 被单。在


如何使用它?在

步骤1

打开终端并运行下面的代码来运行API。 在调用Image_generator类时传递client_secrets.json的路径。在

^{pr2}$


运行上述代码片段后,您将看到您的请求是否已批准,如果批准,则将要求您从Google Drive中选择电子表格。

选择相应的编号,工作表将被导入本地计算机。

您可以在为Image_generator()类创建对象后运行下面的命令来检查电子表格。在

>>>Ig.sheet.head()

If you want to convert a Data type of a column then use the below function.

>>>Ig.convert_dtype(column,type_conversion)

上面的函数将接受两个参数:第一个是要转换的列,第二个是要转换为的类型,比如('int','float'等…)


If you want to convert a Timestamp column to DateTime then use the below function so that we can convert a timestamp dtype column to datetime dtype column.

>>>Ig.convert_timestamp_to_datetime()

上面的函数将要求您从Dataframe中选择一列。在


If you want to generate year column from datetime column in your Data frame then use the below function.

>>>Ig.generate_year()

If you want to generate month column from datetime column in your Data frame then use the below function.

>>>Ig.generate_month()

If you want to generate day column from datetime column in your Data frame then use the below function.

>>>Ig.generate_day()

If you want to group by entire Data frame on a particular column or liat of coluumns then use the below function.

>>>Ig.groupby_column(column)

上述函数将接受一个参数,即单个列或作为列表传递的多个列。在

将图形生成为图像


If you want to plot a Line Graph and save it as an Image then Run the below commnad

>>>Ig.plot_line_graph()

通过运行上述命令,您将被要求选择两列,即一列用于X轴,另一列用于Y轴,它将要求您输入要在本地计算机上存储图像的路径。在


If you want to plot a Bar Graph and save it as an Image then Run the below commnad

>>>Ig.plot_bar_graph()

通过运行上述命令,您将被要求选择两列,即一列用于X轴,另一列用于Y轴,它将要求您输入要在本地计算机上存储图像的路径。在


If you want to plot a Box Plot and save it as an Image then Run the below commnad

>>>Ig.box_plot()

通过运行上述命令,您将被要求选择两列,即一列用于X轴,另一列用于Y轴,它将要求您输入要在本地计算机上存储图像的路径。在


If you want to plot a Scatter Plot and save it as an Image then Run the below commnad

>>>Ig.scatter_plot()

通过运行上述命令,您将被要求选择两列,即一列用于X轴,另一列用于Y轴,它将要求您输入要在本地计算机上存储图像的路径。在

另请参见


  • gsheets.py-用于转储Google所有工作表的自包含脚本 将电子表格转换为CSV或将任何子表转换为熊猫数据帧(此库的Python2原型)
  • gspread-googlespreadsheets Python API(更成熟、更具特色的Python包装器,目前使用基于XML的legacy v3 API

许可证

This Package is licensed under the MIT license. See License for details.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
传递Java处理类类型参数的方式的参数   java安卓中间层admob在logcat中导致大量GC_FOR_ALLOC释放消息   java Vert。x Http请求未将参数分配为配置   java中多线程的输出不正确   如何减少java本地线程的冗余   java不完全分块结果   使用OpenCv时java中的Mat数据类型不受支持错误   Java中的正则表达式不工作,而同一正则表达式在shell中工作   java如何从数组中删除元素?   JDBCJava。sql。SQLException:[Microsoft][ODBC Microsoft Access驱动程序]操作必须使用可更新的查询   java如何以对角线打印字符串变量的字符?   SonarQube 5.2的java自定义插件生成NoClassDefFoundError   macos使用Java应用程序打开浏览器选项卡