Skip to main content

Making dataframes from an excel tabled based on target sum column

Project description

GENERAL

Many times we want an excel table that will result from combinations of additions in a column of our choice. With this package, by selecting the initial excel table, the column and the target number, we will get a dataframe in txt format, which we can then import into an excel table from the external data import option. Of course, the time the results will take depends on the time complexity, i.e. the number of combinations that the program must execute. For this reason there are parameters that you will be able to set and choose if you want it to return the first single result it finds, to return the number of combinations you want, to stop the execution in a time that you have determine.

Instructions

  • Create an instance of the SetExcelColumn class by providing the required parameters:
ec = rowSumExplorer.SetExcelColumn(excel_path='path/to/excel_file.xlsx',
                                    sheet_name='Sheet1',
                                    cell_range='A:1:D:10',
                                    target_sum=100,
                                    n=3,
                                    column_name='Column1',
                                    time_limit=10,
                                    max_combinations=5,
                                    first_result=True)
  • Replace the following parameters based on your needs:
  1. excel_path: Path to the Excel file that contains the table you want to process.

  2. sheet_name: Name of the sheet within the Excel file that contains the table.

  3. cell_range: Range of cells in the format "start_cell:end_cell" that define the table's location.

  4. target_sum: The desired sum you want to achieve by combining rows.

  5. n: Number of rows to combine in each combination.

  6. column_name: The name of the column from which rows will be selected.

  7. time_limit: Maximum time limit (in seconds) for finding combinations. Set to None if there is no time limit.

  8. max_combinations: Maximum number of combinations to find. Set to None if there is no limit.

  9. first_result: Set to True if you want to stop searching after finding the first combination that meets the target sum.

Run the code and specify the output file:

ec.run(output_file='output.txt')

Replace 'output.txt' with the desired file name where the results will be saved.

When you execute the code, it performs the following steps:

Loads the specified Excel file and extracts the table from the given cell range. Finds combinations of rows from the specified column where the sum of values in each combination matches the target sum. Writes the resulting combinations to the output file. If the target sum cannot be reached due to minimum limits, it writes an appropriate message to the output file. Make sure to replace 'path/to/excel_file.xlsx' with the actual path to your Excel file and adjust the other parameters according to your requirements.

#Note

The output file is in a .txt format so you can insert this to an excel sheet via data import

Project details


Release history Release notifications | RSS feed

This version

1.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rowSumExplorer-1.5.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rowSumExplorer-1.5-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file rowSumExplorer-1.5.tar.gz.

File metadata

  • Download URL: rowSumExplorer-1.5.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for rowSumExplorer-1.5.tar.gz
Algorithm Hash digest
SHA256 82240027535f18efdaae31f0815d13b90f16010e713059a0c7577aa88fdaed72
MD5 243b33c7fd71816edc5692adcbc7b3b0
BLAKE2b-256 ce6e44cc34e9c5a6b97055eb7224a8b352063d28d49067f1e97ff50f8ea116a1

See more details on using hashes here.

File details

Details for the file rowSumExplorer-1.5-py3-none-any.whl.

File metadata

  • Download URL: rowSumExplorer-1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for rowSumExplorer-1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 62f3bf0ad5530b345a47a8ba7c77c96f371b18949751aabb9315aa8dce6fafc3
MD5 f537ae365ed62913dbf1721d1a3cf24c
BLAKE2b-256 a2d014f12070c62b5091c7b125acc92d6b3a95e895d02e6d4706f5980e55ec3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page