Q- i have create this so far import numpy as np import pandas as pd import seaborn as…
- User
Q- i have create this so far
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt
path="data/water_potability.csv" df=pd.read_csv(path) df.head()
df.shape
df.info() <class 'pandas.core.frame.DataFrame'> RangeIndex: 3276 entries, 0 to 3275 Data columns (total 10 columns):
Column Non-Null Count Dtype
0 ph 2785 non-null float64 1 Hardness 3276 non-null float64 2 Solids 3276 non-null float64 3 Chloramines 3276 non-null float64 4 Sulfate 2495 non-null float64 5 Conductivity 3276 non-null float64 6 Organic_carbon 3276 non-null float64 7 Trihalomethanes 3114 non-null float64 8 Turbidity 3276 non-null float64 9 Potability 3276 non-null int64
dtypes: float64(9), int64(1) memory usage: 256.1 KBdf.describe() """" now we need to get the percentage of null valus
"""
Q- oky the task in our hand here is to create a “genrale “ function that leverage the functional programming paradigms , using pure function principle oky “Pure functions are a foundational concept in functional programming, characterized by specific principles that enhance code reliability and maintainability. Here are the three key principles of pure functions:
Determinism
A pure function is deterministic, meaning it will always produce the same output when given the same input. This predictability simplifies debugging and reasoning about code, as developers can trust that the function's behavior remains consistent across different contexts[1][3].
No Side Effects
Pure functions do not cause side effects, which means they do not modify any external state or data outside their own scope. They solely rely on their input parameters to compute their output, making them easier to understand and test[2][4].
Referential Transparency
Referential transparency implies that a function can be replaced with its output value without altering the program's behavior. This property allows for easier reasoning about code and facilitates safe transformations and optimizations[1][4].
These principles collectively contribute to the robustness and clarity of functional programming, making it a preferred paradigm for many developers.
Citations: [1] https://adabeat.com/fp/pure-functions-in-functional-programming/ [2] https://blog.rheinwerk-computing.com/what-are-the-principles-of-functional-programming [3] [4] [5] [6] [7] [8] “
- Assistant