# janitor.limit_column_characters¶

janitor.limit_column_characters(df: pandas.core.frame.DataFrame, column_length: int, col_separator: str = '_') → pandas.core.frame.DataFrame[source]

Truncate column sizes to a specific length.

This method mutates the original DataFrame.

Method chaining will truncate all columns to a given length and append a given separator character with the index of duplicate columns, except for the first distinct column name.

Parameters
• df – A pandas dataframe.

• column_length – Character length for which to truncate all columns. The column separator value and number for duplicate column name does not contribute. Therefore, if all columns are truncated to 10 characters, the first distinct column will be 10 characters and the remaining will be 12 characters (assuming a column separator of one character).

• col_separator – The separator to use for counting distinct column values. I think an underscore looks nicest, however a period is a common option as well. Supply an empty string (i.e. ‘’) to remove the separator.

Returns

A pandas DataFrame with truncated column lengths.