A powerfull python tool to create truth tables for logical analysis
Project description
What is pyTruthTable?
This library uses Pandas's dataframe to create logical relations between it's columns. E.g. you can call l_implies(df, n ,m)
that will return a dataframe column with the logical operation "implies" between the column m
and n
(m → n
). The function also names header of the column joining both columns' name with the operation symbol.
How to use?
- Download the file pyTruthTable.py in this repository
- Import the methods using:
from pyTruthTable import * #Import all methods from pyTruthTable
Examples
Example 1
import pandas as pd
from pyTruthTable import * #Import all methods from pyTruthTable
# intialise firs columns.
df = pd.DataFrame({'A':[True, True, False, False],
'B':[True, False, True, False]})
# Create other collumns of the dataframe calling methods
df = df.join(l_implies(df, 0 ,1)) # Thrid column: a->b
df = df.join(l_not(df, 1)) # Forth column: not b
df = df.join(l_and(df, 0, 1)) # Fith column: a and b
df = df.join(l_or(df, 0, 1)) # Sixth column: a or b
df = df.join(l_equals(df, 4, 5)) # Seventh column: fith column <-> sixth column
print(df)
A | B | A → B | ¬B | A ^ B | A ∨ B | (A ^ B) ↔ (A ∨ B) | |
---|---|---|---|---|---|---|---|
0 | True | True | True | False | True | True | True |
1 | True | False | False | True | False | True | False |
2 | False | True | True | False | False | True | False |
3 | False | False | True | True | False | False | True |
Example 2
import pandas as pd
from pyTruthTable import * #Import all methods from pyTruthTable
data = {'Hot':[True, True,True, True, False, False, False, False], # 0
'Wet':[True, True, False, False, True, True, False, False], # 1
'Rains':[True, False, True, False, True, False, True, False]} # 2
df = pd.DataFrame(data)
df = df.join(l_and(df,0,1)) # 3
df = df.join(l_implies(df,3,2)) # 4
df
Hot | Wet | Rains | (Hot) ^ (Wet) | ((Hot) ^ (Wet)) → (Rains) | |
---|---|---|---|---|---|
0 | True | True | True | True | True |
1 | True | True | False | True | False |
2 | True | False | True | False | True |
3 | True | False | False | False | True |
4 | False | True | True | False | True |
5 | False | True | False | False | True |
6 | False | False | True | False | True |
7 | False | False | False | False | True |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyTruthTable-0.0.1.tar.gz
(5.5 kB
view details)
Built Distribution
File details
Details for the file pyTruthTable-0.0.1.tar.gz
.
File metadata
- Download URL: pyTruthTable-0.0.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4a7a62639e589b8adb81a3d9310af3ca05ac4fccfbabcbdf658c83e4c14549a |
|
MD5 | 9350f7b712811c0c733773308c492733 |
|
BLAKE2b-256 | d0b6a1abeaa757f778b67a6271a990243e00eda9061a90c98ae06ebaf1ab3c7b |
File details
Details for the file pyTruthTable-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pyTruthTable-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7c5033f9e9ca86ad029422d4d17eca4fb66f416a42b1747a0ab603d10d9d665 |
|
MD5 | fdb10f1df56f83a36a0fb03b3c475dc2 |
|
BLAKE2b-256 | 4ebe551c41d3796276bc71ccd969bee2b0fae02a73b03106abdde6cafb652503 |