Giter VIP home page Giter VIP logo

pandastopowerpoint's Introduction

PandasToPowerpoint

Python utility to take a Pandas DataFrame and create a Powerpoint table

An example:

from PandasToPowerpoint import df_to_powerpoint

import pandas as pd

df = pd.DataFrame({'District':['Hampshire', 'Dorset', 'Wiltshire', 'Worcestershire'],
				   'Population':[25000, 500000, 735298, 12653],
				   'Ratio':[1.56, 7.34, 3.67, 8.23]})

df_to_powerpoint(r"C:\Code\Powerpoint\test58.pptx", df,
				  col_formatters=['', ',', '.2'], rounding=['', 3, ''])

Documentation

df_to_table

Converts a Pandas DataFrame to a PowerPoint table on the given Slide of a PowerPoint presentation.

The table is a standard Powerpoint table, and can easily be modified with the Powerpoint tools, for example: resizing columns, changing formatting etc.

Arguments:

  • slide: slide object from the python-pptx library containing the slide on which you want the table to appear
  • df: Pandas DataFrame with the data

Optional arguments:

  • col_formatters: A n_columns element long list containing format specifications for each column. For example ['', ',', '.2'] does no special formatting for the first column, uses commas as thousands separators in the second column, and formats the third column as a float with 2 decimal places.
  • rounding: A n_columns element long list containing a number for each integer column that requires rounding that is then multiplied by -1 and passed to round(). The practical upshot of this is that you can give something like ['', 3, ''], which does nothing for the 1st and 3rd columns (as they aren't integer values), but for the 2nd column, rounds away the 3 right-hand digits (eg. taking 25437 to 25000).

df_to_powerpoint

Converts a Pandas DataFrame to a table in a new, blank PowerPoint presentation.

Creates a new PowerPoint presentation with the given filename, with a single slide containing a single table with the Pandas DataFrame data in it.

The table is a standard Powerpoint table, and can easily be modified with the Powerpoint tools, for example: resizing columns, changing formatting etc.

Arguments:

  • filename: Filename to save the PowerPoint presentation as
  • df: Pandas DataFrame with the data

All other arguments that can be taken by df_to_table() (such as col_formatters or rounding) can also be passed here.

pandastopowerpoint's People

Contributors

robintw avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.