move-coop / parsons

A python library of connectors for the progressive community.
Other
255 stars 125 forks source link

[Bug] Some methods listed in documentation are not present in Table class #955

Closed lkesich closed 6 months ago

lkesich commented 6 months ago

Detailed Description

The method rename_columns() is not present when the Table class is imported. Running some_table.rename_columns(name_dict) fails with the error "AttributeError: 'Table' object has no attribute 'rename_columns'."

I ran dir() to get a list of imported Table methods and noticed that rename_columns() is not listed. deduplicate() is also not listed despite appearing in the documentation.

The rename_columns() function works fine when copy/pasted from source code, just not as an attribute of the table object.

To Reproduce

from parsons import Table
tbl = Table()
dir(tbl)

rename_columns and deduplicate are not present in listed methods.

Your Environment

Priority

Low

matthewkrausse commented 6 months ago

Looks like you are using an older version of Parsons. The rename_columns method was added last month (by me). If you want to get the most recent version, you can install like this: python -m pip install git+https://github.com/move-coop/parsons.git.

Even the pip install parsons isn't up to date with that new change.

This is what I get when running the same code in a fresh install using the git+... command.

from parsons import Table
tbl = Table()
dir(tbl)

Output:

['bool', 'class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'getitem', 'gt', 'hash', 'init', 'init_subclass', 'iter', 'le', 'len', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'weakref', '_index_count', '_prepend_dict', '_reprhtml', 'add_column', 'append_csv', 'chunk', 'coalesce_columns', 'column_data', 'columns', 'concat', 'convert_column', 'convert_columns_to_str', 'convert_table', 'cut', 'data', 'deduplicate', 'empty_column', 'fill_column', 'fillna_column', 'first', 'from_bigquery', 'from_columns', 'from_csv', 'from_csv_string', 'from_dataframe', 'from_json', 'from_postgres', 'from_redshift', 'from_s3_csv', 'get_column_max_width', 'get_column_types', 'get_columns_type_stats', 'get_normalized_column_name', 'is_valid_table', 'long_table', 'map_and_coalesce_columns', 'map_columns', 'match_columns', 'materialize', 'materialize_to_file', 'move_column', 'num_rows', 'reduce_rows', 'remove_column', 'remove_null_rows', 'rename_column', 'rename_columns', 'row_data', 'select_rows', 'set_header', 'sort', 'stack', 'table', 'to_bigquery', 'to_civis', 'to_csv', 'to_dataframe', 'to_dicts', 'to_gcs_csv', 'to_html', 'to_json', 'to_petl', 'to_postgres', 'to_redshift', 'to_s3_csv', 'to_sftp_csv', 'to_zip_csv', 'unpack_dict', 'unpack_list', 'unpack_nested_columns_as_rows', 'use_petl']

lkesich commented 6 months ago

Thank you! Those methods appear following install from GitHub. I appreciate your help.