Skip to content

Commit d966dc1

Browse files
committed
Updating the README.md 📝
1 parent 92fcd38 commit d966dc1

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

README.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,57 @@
1-
![image](static/images/poop.jpg)
2-
Pandas dataframes with object oriented programming style
1+
![image](static/images/poop.png)
2+
# Pandas-Oop
3+
(Also known as Poop), is a package that uses Pandas dataframes with object oriented programming style
34

45
Installation:
56
-
67

78
```shell script
89
pip install pandas-oop
910
```
11+
Some examples
12+
-
1013

14+
```python
15+
from pandas_oop import models
16+
```
17+
18+
```python
19+
@models.sql(table='people', con=DB_CONNECTION)
20+
@models.Data
21+
class People(models.DataFrame):
22+
name = models.StringColumn()
23+
age = models.IntegerColumn()
24+
money = models.FloatColumn()
25+
insertion_date = models.DateColumn(format='%d-%m-%Y')
26+
is_staff = models.BoolColumn(true='yes', false='no')
27+
```
28+
29+
Now when instantiating this class, it will return a custom dataframe with all the functionalities of a Pandas
30+
dataframe and some others
31+
32+
```python
33+
people = People()
34+
or
35+
people = People(from_csv=DATA_FILE, delimiter=";")
36+
or
37+
people = People(from_sql_query='select * from people')
38+
```
39+
40+
You can also save it to the database with the save() method (if the dtypes of the columns change, this will raise a
41+
ValidationException):
42+
43+
```python
44+
people.save(if_exists='append', index=False)
45+
```
46+
47+
If you want to revalidate your dataframe (convert the columns dtypes to the type that was declared in the class), you can
48+
call the validate() method:
49+
50+
```python
51+
people.validate()
52+
```
53+
Coming soon
54+
-
55+
functions that are supported on the major databases (sqlite, postgres, oracle, mysql)
56+
- save or update on duplicate
57+
- save or do nothing on duplicate

src/pandas_oop/tests/test_pandas_oop.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class PeopleNoTable(models.DataFrame):
2626
@models.sql(table='people', con=DB_CONNECTION)
2727
@models.Data
2828
class People(models.DataFrame):
29-
3029
name = models.StringColumn()
3130
age = models.IntegerColumn()
3231
money = models.FloatColumn()

static/images/poop.png

19.8 KB
Loading

0 commit comments

Comments
 (0)