pandas-plots 0.0.2__py3-none-any.whl → 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pandas_plots/sql.py ADDED
@@ -0,0 +1,75 @@
1
+ from typing import Literal
2
+
3
+ from sqlalchemy import create_engine, text
4
+ from sqlalchemy_utils import create_database, database_exists
5
+
6
+
7
+ def connect_sql(
8
+ db: str,
9
+ host: str = '',
10
+ user: str = '',
11
+ pw: str = '',
12
+ dbms: Literal['mssql', 'sqlite','postgres'] = 'mssql',
13
+ ensure_db_exists: bool = False,
14
+ ) -> object:
15
+ """
16
+ Connects to any SQL database based on the given parameters.
17
+
18
+ Args:
19
+ db (str): The name of the database / sqlite-file.
20
+ host (str, optional): The host name or IP address of the database server. Defaults to an empty string.
21
+ user (str, optional): The username for authentication. Defaults to an empty string.
22
+ pw (str, optional): The password for authentication. Defaults to an empty string.
23
+ dbms (Literal['mssql', 'sqlite','postgres'], optional): The type of database management system. Defaults to 'mssql'.
24
+ ensure_db_exists (bool, optional): Specifies whether to create the database if it does not exist. Defaults to False.
25
+
26
+ Returns:
27
+ Connection: The connection object for the established database connection.
28
+
29
+ Remarks:
30
+ - postgres
31
+ - psycopg2-binary must be installed
32
+ - example:
33
+ con = my_connect_to_any_sql(
34
+ host='<instance>.postgres.database.azure.com',
35
+ db='eteste',
36
+ user='<user>n@<instance>',
37
+ pw='<password>',
38
+ dbms='postgres',
39
+ ensure_db_exists=False
40
+ )
41
+ - mssql
42
+ - sqlalchemy nust be <v2 to write -> sql
43
+
44
+ """
45
+
46
+ if dbms == 'mssql':
47
+ url = f'mssql://{user}:{pw}@{host}/{db}?driver=ODBC Driver 17 for SQL Server'
48
+ elif dbms == 'sqlite':
49
+ url = f'sqlite:///{db}'
50
+ elif dbms == 'postgres':
51
+ url = f'postgresql+psycopg2://{user}:{pw}@{host}/{db}'
52
+ else:
53
+ print("dbms not supported")
54
+ return None
55
+
56
+ engine = create_engine(
57
+ url, # * leave positional argument unnamed, since it was relabeled between versions..
58
+ connect_args={'connect_timeout': 10},
59
+ )
60
+
61
+ # * ensure db exists
62
+ if ensure_db_exists:
63
+ if not database_exists(engine.url):
64
+ create_database(engine.url)
65
+ print(f'db {db} created')
66
+ else:
67
+ print(f'db {db} exists')
68
+
69
+ # * now connect
70
+ try:
71
+ con=engine.connect()
72
+ except Exception as e:
73
+ print(e)
74
+
75
+ return con
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.1
2
+ Name: pandas-plots
3
+ Version: 0.3.1
4
+ Summary: A collection of helper for pandas n plots
5
+ Author-email: smeisegeier <dsexterDSDo@googlemail.com>
6
+ License: Copyright 2024 smeisegeier
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+
14
+ Project-URL: homepage, https://github.com/smeisegeier/pandas-plots
15
+ Project-URL: repository, https://github.com/smeisegeier/pandas-plots
16
+ Keywords: tables,pivot,plotly
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Development Status :: 5 - Production/Stable
21
+ Classifier: Development Status :: 3 - Alpha
22
+ Classifier: Environment :: Console
23
+ Classifier: Intended Audience :: Science/Research
24
+ Classifier: Operating System :: OS Independent
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: pandas >=2.0.0
30
+ Requires-Dist: plotly
31
+ Requires-Dist: matplotlib
32
+ Requires-Dist: seaborn
33
+ Requires-Dist: sqlalchemy <2.0.0
34
+
35
+ # pandas-plots
36
+
37
+ ![PyPI - Version](https://img.shields.io/pypi/v/pandas-plots) ![GitHub last commit](https://img.shields.io/github/last-commit/smeisegeier/pandas-plots?logo=github) ![GitHub License](https://img.shields.io/github/license/smeisegeier/pandas-plots?logo=github) ![py3.10](https://img.shields.io/badge/python-3.10-blue.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0icHlZZWxsb3ciIGdyYWRpZW50VHJhbnNmb3JtPSJyb3RhdGUoNDUpIj4KICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI2ZlNSIgb2Zmc2V0PSIwLjYiLz4KICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI2RhMSIgb2Zmc2V0PSIxIi8+CiAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPGxpbmVhckdyYWRpZW50IGlkPSJweUJsdWUiIGdyYWRpZW50VHJhbnNmb3JtPSJyb3RhdGUoNDUpIj4KICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iIzY5ZiIgb2Zmc2V0PSIwLjQiLz4KICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iIzQ2OCIgb2Zmc2V0PSIxIi8+CiAgICA8L2xpbmVhckdyYWRpZW50PgogIDwvZGVmcz4KCiAgPHBhdGggZD0iTTI3LDE2YzAtNyw5LTEzLDI0LTEzYzE1LDAsMjMsNiwyMywxM2wwLDIyYzAsNy01LDEyLTExLDEybC0yNCwwYy04LDAtMTQsNi0xNCwxNWwwLDEwbC05LDBjLTgsMC0xMy05LTEzLTI0YzAtMTQsNS0yMywxMy0yM2wzNSwwbDAtM2wtMjQsMGwwLTlsMCwweiBNODgsNTB2MSIgZmlsbD0idXJsKCNweUJsdWUpIi8+CiAgPHBhdGggZD0iTTc0LDg3YzAsNy04LDEzLTIzLDEzYy0xNSwwLTI0LTYtMjQtMTNsMC0yMmMwLTcsNi0xMiwxMi0xMmwyNCwwYzgsMCwxNC03LDE0LTE1bDAtMTBsOSwwYzcsMCwxMyw5LDEzLDIzYzAsMTUtNiwyNC0xMywyNGwtMzUsMGwwLDNsMjMsMGwwLDlsMCwweiBNMTQwLDUwdjEiIGZpbGw9InVybCgjcHlZZWxsb3cpIi8+CgogIDxjaXJjbGUgcj0iNCIgY3g9IjY0IiBjeT0iODgiIGZpbGw9IiNGRkYiLz4KICA8Y2lyY2xlIHI9IjQiIGN4PSIzNyIgY3k9IjE1IiBmaWxsPSIjRkZGIi8+Cjwvc3ZnPgo=)
38
+
39
+ ## usage
40
+
41
+ install / update package
42
+
43
+ ```bash
44
+ pip install pandas-plots -U
45
+ ```
46
+
47
+ include in python
48
+
49
+ ```python
50
+ from pandas_plots import tbl, viz
51
+ ```
52
+
53
+ ## example
54
+
55
+ ```python
56
+ # load sample dataset from seaborn
57
+ import seaborn as sb
58
+ df = sb.load_dataset('taxis')
59
+
60
+ viz.plot_box(df['fare'], height=400, violin=True)
61
+ ```
62
+
63
+ ![plot_box](https://github.com/smeisegeier/pandas-plots/blob/main/img/2024-02-13-00-40-27.png?raw=true)
64
+
65
+ ## why use pandas-plots
66
+
67
+ `pandas-plots` is a package to help you examine and visualize data that are organized in a pandas DataFrame. It provides a high level api to pandas / plotly with some selected functions.
68
+
69
+ It is subdivided into:
70
+
71
+ - `tbl` utilities for table descriptions
72
+ - `describe_df()` an alternative version of pandas `describe()` function
73
+ - `pivot_df()` gets a pivot table of a 3 column dataframe
74
+
75
+ - `viz` utilities for plotly visualizations
76
+ - `plot_box()` auto annotated boxplot w/ violin option
77
+ - `plot_boxes()` multiple boxplots _(annotation is experimental)_
78
+ - `plots_bars()` a standardized bar plot
79
+ - `plot_stacked_bars()` shortcut to stacked bars 😄
80
+ - `plot_quadrants()` quickly show a 2x2 heatmap
81
+
82
+ - `sql` is added as convienient wrapper for fetching data from sql databases
83
+ - `connect_sql` get data from `['mssql', 'sqlite','postgres']`
84
+
85
+ ## dependencies
@@ -0,0 +1,9 @@
1
+ pandas_plots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ pandas_plots/sql.py,sha256=SHrmwhmzq0QYygvaoKwv7neiwf_Rv87VmdUkADYPdR8,2485
3
+ pandas_plots/tbl.py,sha256=7_o-Mu2nrniZd25zAtb_7IUdi7ZUnjcn9OFpBwFcVno,11500
4
+ pandas_plots/viz.py,sha256=eCDth3aFSU0_8Cj5Tax-FWM9TmPrmmNEiFuoVOB63ss,23207
5
+ pandas_plots-0.3.1.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
6
+ pandas_plots-0.3.1.dist-info/METADATA,sha256=VC7bKNzOVxg0GyvBSAyZm0gfKZB8g0BdzrWpEhFvZL0,4983
7
+ pandas_plots-0.3.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
8
+ pandas_plots-0.3.1.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
9
+ pandas_plots-0.3.1.dist-info/RECORD,,
@@ -1,56 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pandas-plots
3
- Version: 0.0.2
4
- Summary: A collection of helper for pandas n plots
5
- Author-email: smeisegeier <dsexterDSDo@googlemail.com>
6
- License: Copyright 2024 smeisegeier
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
-
12
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
-
14
- Project-URL: Homepage, https://github.com/smeisegeier/pandas-plots
15
- Keywords: tables,pivot,plotly
16
- Classifier: License :: OSI Approved :: MIT License
17
- Classifier: Programming Language :: Python :: 3
18
- Requires-Python: >=3.10
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: pandas >=2.0.0
22
- Requires-Dist: plotly
23
- Requires-Dist: matplotlib
24
- Requires-Dist: seaborn
25
-
26
- # pandas-plots
27
-
28
- ## quickstart
29
-
30
- ```bash
31
- pip install pandas-plots -U
32
- ```
33
-
34
- ```python
35
- import pandas_plots as pp
36
- pp.pandas.describe_df()
37
- ```
38
-
39
- ## why use pandas-plots
40
-
41
- `pandas-plots` is a package to help you examine and visualize data that are organized in a pandas DataFrame. It provides a high level api to pandas / plotly with some selected functions.
42
-
43
- It is subdivided into:
44
-
45
- - `tbl` utilities for table descriptions
46
- - `describe_df()` an alternative version of pandas `describe()` function
47
- - `pivot_df()` gets a pivot table of a 3 column dataframe
48
-
49
- - `viz` utilities for plotly visualizations
50
- - `plot_box()` auto annotated boxplot w/ violin option
51
- - `plot_boxes()` multiple boxplots _(annotation is experimental)_
52
- - `plots_bars()` a standardized bar plot
53
- - `plot_stacked_bars()` shortcut to stacked bars 😄
54
- - `plot_quadrants()` quickly show a 2x2 heatmap
55
-
56
- ## dependencies
@@ -1,8 +0,0 @@
1
- pandas_plots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pandas_plots/tbl.py,sha256=7_o-Mu2nrniZd25zAtb_7IUdi7ZUnjcn9OFpBwFcVno,11500
3
- pandas_plots/viz.py,sha256=eCDth3aFSU0_8Cj5Tax-FWM9TmPrmmNEiFuoVOB63ss,23207
4
- pandas_plots-0.0.2.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
5
- pandas_plots-0.0.2.dist-info/METADATA,sha256=QboWQtO4kKqA2h0cwsn3q0mpNhXORbT8_wjtGprEVz4,2549
6
- pandas_plots-0.0.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
7
- pandas_plots-0.0.2.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
8
- pandas_plots-0.0.2.dist-info/RECORD,,