# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['neat_panda']

package_data = \
{'': ['*']}

install_requires = \
['pandas>=1.0.3', 'pandas_flavor>=0.1.2', 'toml>=0.10.0']

setup_kwargs = {
    'name': 'neat-panda',
    'version': '0.9.7',
    'description': '',
    'long_description': '\n# Neat Panda\n\n[![pypi](https://img.shields.io/pypi/v/neat_panda.svg)](https://pypi.python.org/pypi/neat_panda)\n[![Build Status](https://dev.azure.com/henricsundberg/neat_panda/_apis/build/status/htp84.neat_panda?branchName=master)](https://dev.azure.com/henricsundberg/neat_panda/_build/latest?definitionId=1&branchName=master)\n[![](https://img.shields.io/azure-devops/build/henricsundberg/neat_panda/1/master.svg)]()\n[![](https://img.shields.io/azure-devops/coverage/henricsundberg/neat_panda/1/master.svg)]()\n[![](https://img.shields.io/azure-devops/tests/henricsundberg/neat_panda/1/master.svg?passed_label=good&failed_label=bad&skipped_label=n%2Fa</code>)]()\n[![Supported](https://img.shields.io/pypi/pyversions/neat_panda.svg)](https://pypi.python.org/pypi/neat_panda)\n\n\nNeat Panda contains three main methods/functions, spread, gather and clean_columnames. The ideas for these methods are from the spread and gather functions in the R package [*tidyr*](https://tidyr.tidyverse.org/) and the make_clean_columns function in the R package [*janitor*](https://github.com/sfirke/janitor).\n\nThe spread function is syntactic sugar for the [*pandas*](https://pandas.pydata.org/pandas-docs/stable/) library method [*pivot*](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.pivot.html) and the gather method is syntactic sugar for the pandas method [*melt*](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.melt.html).\n\n\n## Features\n### clean_column_names\n```python\nimport neat_panda\n\nprint(df.columns.tolist())\n["Country    ", "Sub$region", "Actual"]\n\ndf = df.clean_column_names()\n\nprint(df.columns.tolist())\n["country", "sub_region", "actual"]\n\n```\n\n### spread\n#### R\n```R\nlibrary(tidyr)\nlibrary(dplyr)\nlibrary(gapminder)\n\ngapminder2 <- gapminder %>% select(country, continent, year, pop)\ngapminder3 <- gapminder2 %>% spread(key = year, value = pop)\nhead(gapminder3, n = 5)\n```\n#### Python\n```python\nimport neat_panda\nfrom gapminder import gapminder\n\ngapminder2 = gapminder[["country", "continent", "year", "pop"]]\ngapminder3 = gapminder2.spread(key="year", value="pop")\n\ngapminder3.head()\n```\n##### Output R\n```\n# A tibble: 5 x 14\n  country     continent   `1952`   `1957`   `1962`   `1967`   `1972`   `1977`   `1982`   `1987`   `1992`   `1997`   `2002`   `2007`\n  <fct>       <fct>        <int>    <int>    <int>    <int>    <int>    <int>    <int>    <int>    <int>    <int>    <int>    <int>\n1 Afghanistan Asia       8425333  9240934 10267083 11537966 13079460 14880372 12881816 13867957 16317921 22227415 25268405 31889923\n2 Albania     Europe     1282697  1476505  1728137  1984060  2263554  2509048  2780097  3075321  3326498  3428038  3508512  3600523\n3 Algeria     Africa     9279525 10270856 11000948 12760499 14760787 17152804 20033753 23254956 26298373 29072015 31287142 33333216\n4 Angola      Africa     4232095  4561361  4826015  5247469  5894858  6162675  7016384  7874230  8735988  9875024 10866106 12420476\n5 Argentina   Americas  17876956 19610538 21283783 22934225 24779799 26983828 29341374 31620918 33958947 36203463 38331121 40301927\n```\n##### Output Python\n```\n       country continent      1952      1957      1962      1967      1972      1977      1982      1987      1992      1997      2002      2007\n0  Afghanistan      Asia   8425333   9240934  10267083  11537966  13079460  14880372  12881816  13867957  16317921  22227415  25268405  31889923\n1      Albania    Europe   1282697   1476505   1728137   1984060   2263554   2509048   2780097   3075321   3326498   3428038   3508512   3600523\n2      Algeria    Africa   9279525  10270856  11000948  12760499  14760787  17152804  20033753  23254956  26298373  29072015  31287142  33333216\n3       Angola    Africa   4232095   4561361   4826015   5247469   5894858   6162675   7016384   7874230   8735988   9875024  10866106  12420476\n4    Argentina  Americas  17876956  19610538  21283783  22934225  24779799  26983828  29341374  31620918  33958947  36203463  38331121  40301927\n```\n\n\n### gather\n#### R\n```R\nlibrary(tidyr)\n\n# gapminder3 is obtained as above\ngapminder4 <- gather(gapminder3, key="year", "value"="pop", 3:14)\n# or\nyears <- c("1952", "1957", "1962", "1967", "1972", "1977", "1982", "1987", "1992", "1997", "2002", "2007")\ngapminder4 <- gather(gapminder3, key="year", "value"="pop", years)\n\nhead(gapminder4, n = 5)\n```\n#### Python\n```python\nimport neat_panda\n\n# gapminder3 is obtained as above\ngapminder4 = gapminder3.gather(key="year", value="pop", columns=range(2, 13))\n# or\ngapminder4 = gapminder3.gather(key="year", value="pop", columns=range(0, 2), invert_columns=True)\n# or\nyears = ["1952", "1957", "1962", "1967", "1972", "1977", "1982", "1987", "1992", "1997", "2002", "2007"]\ngapminder4 = gapminder3.gather(key="year", value="pop", columns=years)\n# or\ngapminder4 = gapminder3.gather(key="year", value="pop", columns=["country", "continent"], invert_columns=True)\n\ngapminder4.head()\n```\n##### Output R\n```\n# A tibble: 5 x 4\n  country     continent year       pop\n  <fct>       <fct>     <chr>    <int>\n1 Afghanistan Asia      1952   8425333\n2 Albania     Europe    1952   1282697\n3 Algeria     Africa    1952   9279525\n4 Angola      Africa    1952   4232095\n5 Argentina   Americas  1952  17876956\n```\n##### Output Python\n```\n       country continent  year       pop\n0  Afghanistan      Asia  1952   8425333\n1      Albania    Europe  1952   1282697\n2      Algeria    Africa  1952   9279525\n3       Angola    Africa  1952   4232095\n4    Argentina  Americas  1952  17876956\n\n```\n',
    'author': 'Henric Sundberg,',
    'author_email': 'henric.sundberg@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/htp84/neat_panda',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
