xxxxxxxxxx
diff_df = pd.merge(df1, df2, how='outer', indicator='Exist')
diff_df = diff_df.loc[diff_df['Exist'] != 'both']
xxxxxxxxxx
source_df.merge(target_df,how='left',indicator=True).loc[lambda x:x['_merged']!='both']
xxxxxxxxxx
df1.merge(df2,indicator = True, how='left').loc[lambda x : x['_merge']!='both']
Out[421]:
A B _merge
1 2 3 left_only
2 3 4 left_only
3 3 4 left_only
xxxxxxxxxx
# by doing outer, you will get records from both the sides.
f = df1.merge(df2,indicator = True, how='outer').loc[lambda x : x['_merge']!='both']
Out[421]:
A B _merge
1 2 3 left_only
2 3 4 left_only
3 3 4 left_only
left_unique_result = f.loc[lambda x: x['_merge'] == 'left_only']
right_unique_result = f.loc[lambda x: x['_merge'] == 'right_only']
xxxxxxxxxx
TOML (Tom's Obvious, Minimal Language) is a lightweight configuration file format that is easy to read and write. Python's built-in tomllib (Python 3.11+) or toml package (for earlier versions) can be used to parse TOML files.
Reading a TOML File in Pythonimport tomllib # Python 3.11+ (For older versions, use 'import toml' after installing `toml` package)
# Read TOML file
with open("config.toml", "rb") as file:
config = tomllib.load(file)
# Access values
print(config["database"]["host"]) # Output: localhost
print(config["database"]["port"]) # Output: 5432
Example config.toml File[database]
host = "localhost"
port = 5432
user = "admin"
password = "securepass"
[server]
debug = true
port = 8080