GithubHelp home page GithubHelp logo

ravidevops10am / xlformulas Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joetats/xlformulas

0.0 1.0 0.0 6 KB

Helper class to write Excel-style formula strings to worksheets when saving from a Pandas dataframe.

License: MIT License

Python 100.00%

xlformulas's Introduction

xlFormulas

Helper class to write Excel-style formula strings to worksheets when saving from a Pandas dataframe.

Default initialization assumes the worksheet will be saved with an index and header row (the first real 'data' cell would be B2) but an index and header parameter are available to ensure alignment.

Pass in mathematical operators with strings, limited support currently for Excel built-in functions. If a value is not a column name in df.columns it is passed in as it is, whether that means it's an operator or builtin function.

The .formula() method returns a list of strings beginning with '=' and containing the row index for the Excel formula

Installation:

pip install xl-formulas

Basic usage:

import pandas as pd
from xlFormulas import ExcelFormulas

df = pd.read_excel('sample_data.xlsx')

# Pass in Pandas dataframe to intialize ExcelFormulas helper
ef = ExcelFormulas(df)

# Returns a column like "=B2+C2" in df['C']
df['C'] = ef.formula('A + B')

# Makes a "=(B2 + C2)/(C2 - D2)" column in df['D']
df['D'] = ef.formula(f'{ef.paren('A + B')} / {ef.paren('B - C')}'

# Use Excel built-in functions (Still pretty buggy)
# This would get a column of "=SUM(B2,C2,5)" in df['E']
df['E'] = ef.formula(ef.builtin('SUM', 'A', 'B', 'C'))

xlformulas's People

Contributors

joetats avatar

Watchers

James Cloos 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.