{"id":26517057,"url":"https://github.com/hansalemaos/prettycolorprinter","last_synced_at":"2025-12-14T15:35:33.767Z","repository":{"id":54469663,"uuid":"522359299","full_name":"hansalemaos/PrettyColorPrinter","owner":"hansalemaos","description":"Function to color pretty print pandas, numpy, lists, dicts","archived":false,"fork":false,"pushed_at":"2024-02-23T00:01:09.000Z","size":2289,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T23:03:18.891Z","etag":null,"topics":["color","color-print","color-printing","numpy","pandas"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/PrettyColorPrinter/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hansalemaos.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-08T00:37:56.000Z","updated_at":"2024-12-07T15:58:45.000Z","dependencies_parsed_at":"2024-11-15T02:59:51.781Z","dependency_job_id":"d4c41488-fad1-4da9-bca9-d5731b1ca46d","html_url":"https://github.com/hansalemaos/PrettyColorPrinter","commit_stats":null,"previous_names":["hansalemaos/pandascolorprinter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2FPrettyColorPrinter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2FPrettyColorPrinter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2FPrettyColorPrinter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2FPrettyColorPrinter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hansalemaos","download_url":"https://codeload.github.com/hansalemaos/PrettyColorPrinter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244759961,"owners_count":20505716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color","color-print","color-printing","numpy","pandas"],"created_at":"2025-03-21T08:17:55.855Z","updated_at":"2025-12-14T15:35:33.714Z","avatar_url":"https://github.com/hansalemaos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Print colored Numpy arrays / pandas DataFrames / Pandas Series / lists / dicts / tuples!**\n\n```python\npip install PrettyColorPrinter\n```\n\n#### **This is everything you have to do to use PrettyColorPrinter with pandas**\n\n```python\nfrom PrettyColorPrinter import add_printer\nadd_printer() #This function will add some methods to PandasObject\n\n#Let’s import pandas and create a DataFrame:\n\nimport pandas as pd\ndf=pd.read_csv(r\"https://github.com/pandas-dev/pandas/raw/main/doc/data/air_quality_no2_long.csv\")\n```\n\n### Update 2022/12/27\n\nYou can switch between the colored version and the black/white version. \n\n```python\nimport pandas as pd\r\nfrom PrettyColorPrinter import add_printer, switch_color_bw\r\nadd_printer(True)\r\nswitch_color_bw()\r\n\n```\n\n### Update 2022/10/08\n\nFixed a bug with empty DataFrames\n\n### **Update 2022/10/05**\n\n```python\nadd_printer(overwrite_pandas_printer=False)\nIf you pass overwrite_pandas_printer=True then the color printer will replace __str__ and __repr__ from pandas\n\nYou can configure the color printer using:\n     pd.color_printer_activate(print_stop:int=69,max_colwidth:int=300,repeat_cols:int=70)\n     print_stop = maximum lines to print\n     max_colwidth = maximum column width\n     repeat_cols = for better readability, the columns are printed each x row\n\n\n    This is how you switch back and forth between standard pandas and color printer:\n      pd.color_printer_reset() #to standard pandas\n      pd.color_printer_activate() #to color printer\n```\n\n### Have a look\n\n```python\nfrom PrettyColorPrinter import add_printer\nfrom a_pandas_ex_plode_tool import pd_add_explode_tools\nimport pandas as pd\npd_add_explode_tools()\nadd_printer(overwrite_pandas_printer=True)\ndata={'critic_reviews': [{'review_critic': 'XYZ', 'review_score': 90},\n                    {'review_critic': 'ABC', 'review_score': 90},\n                    {'review_critic': '123', 'review_score': 90}],\n 'genres': ['Sports', 'Golf'],\n 'score': 85,\n 'title': 'Golf Simulator',\n 'url': 'http://example.com/golf-simulator'}\ndf = pd.Q_AnyNestedIterable_2df(data,unstack=False) #multiindex \ndf2 = df.d_unstack() #normal index\ndf #if you type df, you will get a colored dataframe instead of the regular pandas version\n```\n\n![](https://github.com/hansalemaos/PrettyColorPrinter/raw/main/a12.png)\n\n![](https://github.com/hansalemaos/PrettyColorPrinter/raw/main/a13.png)\n\n\u003cimg title=\"\" src=\"https://github.com/hansalemaos/PrettyColorPrinter/raw/main/a11.png\" alt=\"\"\u003e\n\n**All methods added to pandas start either with:**\n\n- **ds_** (for DataFrames and Series)\n\n- **s_** (only for Series) \n\n- **d_** (only for DataFrames)\n\n### **All methods that are added to PandasObject**\n\n- **ds_color_print**\n\n- **ds_color_print_all**\n\n- **d_color_print_columns**\n\n- **d_color_print_index**\n\n- **ds_color_print_all_with_break**\n\n- **ds_color_print_context**\n\n```python\n#If you want to see some examples:\nfrom PrettyColorPrinter import print_test_from_pandas_github\nprint_test_from_pandas_github()\n\n#If you need help\nhelp(df.ds_color_print)\nqq_ds_print(max_rows: int = 1000, max_colwidth: int = 300, repeat_cols: int = 70, asnumpy: bool = False, returndf: bool = False) -\u003e Union[pandas.core.frame.DataFrame, pandas.core.series.Series, NoneType] method of pandas.core.frame.DataFrame instance\n    Parameters\n    ----------\n    df : pd.DataFrame, pd.Series\n        Array to print\n    max_rows : int\n        Stop printing after n lines (default is 1000)\n    max_colwidth : int\n        Width of each column (default is 300)\n    repeat_cols : int (default is 70)\n        Print columns again after n lines  (default is 70)\n    asnumpy: bool (default is False)\n        Converts pandas DataFrame to np before printing.\n        If there are duplicated columns in a Pandas DataFrame,\n        it changes to printasnp = True  (default is False)\n    returndf:  bool (default is False)\n        return the input DataFrame to allow chaining\n```\n\n### Using PrettyColorPrinter without pandas\n\n**\n\nThe function **pdp** can be used without pandas.   \nDoing it this way, you are not restricted to PandasObjects.\n\n**You can print lists, dicts, tuples, np.arrays, pd.DataFrames and pd.Series**\n\n**\n\n```python\nfrom PrettyColorPrinter import pdp\n```\n\n\u003cimg title=\"\" src=\"https://github.com/hansalemaos/PrettyColorPrinter/raw/main/a1.png\" alt=\"\"\u003e\n\u003cimg title=\"\" src=\"https://github.com/hansalemaos/PrettyColorPrinter/raw/main/a2.png\" alt=\"\"\u003e\n\u003cimg title=\"\" src=\"https://github.com/hansalemaos/PrettyColorPrinter/raw/main/a3.png\" alt=\"\"\u003e\n\u003cimg title=\"\" src=\"https://github.com/hansalemaos/PrettyColorPrinter/raw/main/a5.png\" alt=\"\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fprettycolorprinter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansalemaos%2Fprettycolorprinter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fprettycolorprinter/lists"}