Skip to content

Commit

Permalink
#8 Adds documentation regarding usage of ListDisplayFilter, ObjectDis…
Browse files Browse the repository at this point in the history
…playFilter, SQLDisplayFilter
  • Loading branch information
bytebutcher committed Jul 7, 2023
1 parent b45b340 commit 27ca0d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ pip3 install pydfql
Next, import the necessary module and initialize the appropriate display filter with some data.
In the example below we are initializing the ```ObjectDisplayFilter``` with a list of objects:
```python
from dataclasses import dataclass
from pydfql import ObjectDisplayFilter

@dataclass
class Actor:
def __init__(self, name, age, gender):
self.name = name
self.age = age
self.gender = gender
name: list
age: dict
gender: str

actors = [
Actor(["Laurence", "Fishburne"], {"born": "1961"}, "male"),
Expand All @@ -68,9 +69,9 @@ filter_query = "age.born > 1960"
filtered_data = df.filter(filter_query)
print(list(filtered_data))
[
{"name": ["Laurence", "Fishburne"], "age": {"born": "1961"}, "gender": "male"},
{"name": ["Keanu", "Reeves"], "age": {"born": "1964"}, "gender": "male", "power": ["flight", "bullet-time"]},
{"name": ["Carrie-Anne", "Moss"], "age": {"born": "1967"}, "gender": "female"}
Actor(name=["Laurence", "Fishburne"], age={"born": "1961"}, gender="male"),
Actor(name=["Keanu", "Reeves"], age={"born": "1964"}, gender="male"),
Actor(name=["Carrie-Anne", "Moss"], age={"born": "1967"}, gender="female")
]
```

Expand Down
19 changes: 9 additions & 10 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,20 @@ The ```ObjectDisplayFilter``` enables filtering a list of objects.
**Example:**

```python
from dataclasses import dataclass
from pydfql import ObjectDisplayFilter


@dataclass
class Actor:
def __init__(self, name, age, gender):
self.name = name
self.age = age
self.gender = gender

name: list
age: dict
gender: str

actors = [
Actor(["Laurence", "Fishburne"], {"born": "1961"}, "male"),
Actor(["Keanu", "Reeves"], {"born": "1964"}, "male"),
Actor(["Joe", "Pantoliano"], {"born": "1951"}, "male"),
Actor(["Carrie-Anne", "Moss"], {"born": "1967"}, "female")
Actor(["Laurence", "Fishburne"], {"born": "1961"}, "male"),
Actor(["Keanu", "Reeves"], {"born": "1964"}, "male"),
Actor(["Joe", "Pantoliano"], {"born": "1951"}, "male"),
Actor(["Carrie-Anne", "Moss"], {"born": "1967"}, "female")
]

filter_query = "age.born > 1960"
Expand Down

0 comments on commit 27ca0d4

Please sign in to comment.