# Please install this package using following command.
# $ pip install pandas-validator
import pandas_validator as pv

import pandas as pd
import numpy as np

"""
Explanation: pandas-validator example
This is example of pandas-validator in English.
End of explanation
"""


# Create validator's instance
validator = pv.IntegerSeriesValidator(min_value=0, max_value=10)

series = pd.Series([0, 3, 6, 9])  # This series is valid.
print(validator.is_valid(series))

series = pd.Series([0, 4, 8, 12])  # This series is invalid. because that includes 12 number.
print(validator.is_valid(series))

"""
Explanation: Series Validator
End of explanation
"""


# Define validator
class SampleDataFrameValidator(pv.DataFrameValidator):
    row_num = 5
    column_num = 2
    label1 = pv.IntegerColumnValidator('label1', min_value=0, max_value=10)
    label2 = pv.FloatColumnValidator('label2', min_value=0, max_value=10)

# Create validator's instance
validator = SampleDataFrameValidator()

df = pd.DataFrame({'label1': [0, 1, 2, 3, 4], 'label2': [5.0, 6.0, 7.0, 8.0, 9.0]})  # This data frame is valid.
print(validator.is_valid(df))

df = pd.DataFrame({'label1': [11, 12, 13, 14, 15], 'label2': [5.0, 6.0, 7.0, 8.0, 9.0]})  # This data frame is invalid.
print(validator.is_valid(df))

df = pd.DataFrame({'label1': [0, 1, 2], 'label2': [5.0, 6.0, 7.0]})  # This data frame is invalid.
print(validator.is_valid(df))

"""
Explanation: DataFrame Validator
DataFrameValidator class can validate panda's dataframe object.
It can define easily like Django's model definition.
End of explanation
"""


