Repository: cosmicBboy/pandera

Issue:
create CONTRIBUTING.md with dataframe schema style-guide
based on conversation here:
https://github.com/cosmicBboy/pandera/pull/34

Discussion:

Patch:
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
new file mode 100644
index 0000000..fdd5af9
--- /dev/null
+++ b/.github/CONTRIBUTING.md
@@ -0,0 +1,73 @@
+# Contributing to pandera
+
+Whether you are a novice or experienced software developer, all contributions
+and suggestions are welcome!
+
+## Getting Started
+
+If you are looking to contribute to the *pandera* codebase, the best place to
+start is the [GitHub "issues" tab](https://github.com/cosmicBboy/pandera/issues).
+This is also a great place for filing bug reports and making suggestions for
+ways in which we can improve the code and documentation.
+
+## Contributing to the Codebase
+
+The code is hosted on [GitHub](https://github.com/cosmicBboy/pandera/issues),
+so you will need to use [Git](http://git-scm.com/) to clone the project and make
+changes to the codebase. Once you have obtained a copy of the code, you should
+create a development environment that is separate from your existing Python
+environment so that you can make and test changes without compromising your
+own work environment.
+
+### Dataframe Style Guides
+We have guidelines regarding dataframe and schema styles that are enforced for
+each pull request:
+
+- If specifying a single column DataFrame, this can be expressed as a one-liner:
+```DataFrameSchema({"col1": Column(...)})```
+
+- If specifying one column with multiple lines, or multiple columns:
+    ```
+    DataFrameSchema({
+        "col1": Column(type, checks=[
+            Check(...),
+            Check(...),
+        ]),
+    })
+    
+    
+    DataFrameSchema({
+        "col1": Column(...),
+        "col2": Column(...),
+    })
+    ```
+
+- If specifying single columns with additional arguments
+    ```
+    DataFrameSchema({"a": Column(Int, nullable=True)},
+                    strict=True)
+    ```
+
+- If specifying columns with additional arguments
+    ```
+    DataFrameSchema(
+        {
+            "col1": Column(...),
+            "col2": Column(...),
+        },
+        strict=True)
+    ```
+
+### Run the tests
+Before submitting your changes for review, make sure to check that your changes
+do not break any tests by running ``pytest tests/``. You can find more
+information about our test suites in the "[Test-driven development/code writing](https://github.com/pandas-dev/pandas/blob/master/doc/source/development/contributing.rst#test-driven-development-code-writing)"
+section.
+
+### Raising Pull Requests
+
+Once your changes are ready to be submitted, make sure to push your changes to
+your fork of the GitHub repo before creating a pull request.  We will review
+your changes, and might ask you to make additional changes before it is finally
+ready to merge. However, once it's ready, we will merge it, and you will have
+successfully contributed to the codebase!
\ No newline at end of file
diff --git a/README.md b/README.md
index 79c67b7..d20d251 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
 # pandera
 
 [![Build Status](https://travis-ci.org/cosmicBboy/pandera.svg?branch=master)](https://travis-ci.org/cosmicBboy/pandera)
+[![PyPI version shields.io](https://img.shields.io/pypi/v/pandera.svg)](https://pypi.org/project/pandera/)
+[![PyPI license](https://img.shields.io/pypi/l/pandera.svg)](https://pypi.python.org/pypi/pandera/)
 
 **Supports:** python 2.7, 3.5, 3.6
 
-Validating pandas data structures for people seeking correct things.
-
 A light-weight and flexible validation package for
 [pandas](http://pandas.pydata.org) data structures.
 
@@ -255,11 +255,12 @@ schema_float.validate(df).dtypes
 If you want to coerce all of the columns specified in the `DataFrameSchema`,
 you can specify the `coerce` argument with `DataFrameSchema(..., coerce=True)`.
 
-### Required columns
+### Required Columns
 
-By default all columns specified in the schema are required, meaning that if a column is missing in the input
-dataframe an exception will be thrown. If you want to make a column optional specify `required=False`
-in the column constructor:
+By default all columns specified in the schema are required, meaning that if a
+column is missing in the input dataframe an exception will be thrown. If you
+want to make a column optional specify `required=False` in the column
+constructor:
 
 ```python
 import pandas as pd
@@ -277,6 +278,25 @@ validated_df = schema.validate(df)
 
 ```
 
+### Handling of Dataframe Columns not in the Schema
+
+By default, columns that aren't specified in the schema aren't checked. If you
+want to check that the dataframe *only* contains columns in the schema, specify
+`strict=True`:
+
+```python
+import pandas as pd
+from pandera import Column, DataFrameSchema, Int
+
+schema = DataFrameSchema({"column1": Column(Int, nullable=True)},
+                         strict=True)
+df = pd.DataFrame({"column2": [1, 2, 3]})
+
+schema.validate(df)
+
+# SchemaError: column 'column2' not in DataFrameSchema {'column1': <Schema Column: 'None' type=int64>}
+```
+
 ### `SeriesSchema`
 
 ```python
@@ -435,16 +455,21 @@ zero_column_1_dict(preprocessed_df)
 zero_column_1_custom(preprocessed_df)
 ```
 
-Tests
------
+## Tests
+
 
 ```
 pip install pytest
 pytest tests
 ```
 
-Issues
-------
+## Contributing to pandera [![GitHub contributors](https://img.shields.io/github/contributors/cosmicBboy/pandera.svg)](https://github.com/cosmicBboy/pandera/graphs/contributors)
+All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome.
+
+A detailed overview on how to contribute can be found in the [contributing guide](https://github.com/cosmicBboy/pandera/blob/master/.github/CONTRIBUTING.md) on GitHub.
+
+## Issues
+
 
 Go [here](https://github.com/cosmicBboy/pandera/issues) to submit feature
 requests or bugfixes.
diff --git a/pandera/pandera.py b/pandera/pandera.py
index 1398a6f..a35ca02 100644
--- a/pandera/pandera.py
+++ b/pandera/pandera.py
@@ -134,7 +134,7 @@ class Check(object):
 class DataFrameSchema(object):
     """A light-weight pandas DataFrame validator."""
 
-    def __init__(self, columns, index=None, transformer=None, coerce=False):
+    def __init__(self, columns, index=None, transformer=None, coerce=False, strict=False):
         """Initialize pandas dataframe schema.
 
         Parameters
@@ -150,13 +150,27 @@ class DataFrameSchema(object):
             columns and return the transformed dataframe object.
         coerce : bool
             whether or not to coerce all of the columns on validation.
+        strict : bool
+            whether or not to accept columns in the dataframe that aren't in the
+            DataFrame Schema.
         """
         self.index = index
         self.columns = columns
         self.transformer = transformer
         self.coerce = coerce
+        self.strict = strict
 
     def validate(self, dataframe):
+        # Check if all columns in the dataframe have a corresponding column in
+        # the DataFrameSchema
+        if self.strict:
+            for column in dataframe:
+                if column not in self.columns:
+                    raise SchemaError(
+                        "column '%s' not in DataFrameSchema %s" %
+                        (column, self.columns)
+                    )
+
         for c, col in self.columns.items():
             if c not in dataframe and col.required:
                 raise SchemaError(
diff --git a/setup.py b/setup.py
index 8d74ac9..0dee948 100644
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,16 @@
 from setuptools import setup
 
+with open('README.md') as f:
+    long_description = f.read()
 
 setup(
     name="pandera",
     version="0.1.2",
     author="Niels Bantilan",
     author_email="niels.bantilan@gmail.com",
-    description="A pandas data structure validation library",
+    description = 'A light-weight and flexible validation package for pandas data structures.',
+    long_description=long_description,
+    long_description_content_type='text/markdown',
     url="https://github.com/cosmicBboy/pandera",
     keywords=["pandas", "validation", "data-structures"],
     license="MIT",
@@ -19,4 +23,6 @@ setup(
         "pandas >= 0.23.0",
         "wrapt",
     ],
-)
+    python_requires='>=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4',
+    platforms='any',
+)
\ No newline at end of file


Test patch:
diff --git a/tests/test_pandera.py b/tests/test_pandera.py
index 889a199..65f1f23 100644
--- a/tests/test_pandera.py
+++ b/tests/test_pandera.py
@@ -112,6 +112,17 @@ def test_dataframe_schema():
     with pytest.raises(SchemaError):
         schema.validate(df.assign(a=[1.7, 2.3, 3.1]))
 
+
+def test_dataframe_schema_strict():
+    # checks if strict=True whether a schema error is raised because 'a' is not
+    # present in the dataframe.
+    schema = DataFrameSchema({"a": Column(Int, nullable=True)},
+                             strict=True)
+    df = pd.DataFrame({"b": [1, 2, 3]})
+    with pytest.raises(SchemaError):
+        schema.validate(df)
+
+
 def test_index_schema():
     schema = DataFrameSchema(
         columns={},