Repository: pandas-dev/pandas

Issue:
spaces converted to todays date with to_datetime and read_csv date parse
```
In [265]: s = pd.Series(['10/18/2006', '10/18/2008', ' '])

In [266]: pd.to_datetime(s)
Out[266]:
0   2006-10-18
1   2008-10-18
2   2014-02-20
dtype: datetime64[ns]

In [268]: pd.to_datetime(s, errors='raise')
Out[268]:
0   2006-10-18
1   2008-10-18
2   2014-02-20
dtype: datetime64[ns]
```

_Note: Can use `pd.to_datetime(s, format='%m/%d/%Y', coerce=True)`._

This also seems to be the case when reading from csv.

```
csv = """case,opdate
7,10/18/2006
7,10/18/2008
621, """

In [282]: pd.read_csv(StringIO(csv), parse_dates=['opdate'])
Out[282]:
   case     opdate
0     7 2006-10-18
1     7 2008-10-18
2   621 2014-02-20

[3 rows x 2 columns]
```

See this SO question http://stackoverflow.com/questions/21922978/safest-pandas-read-csv-with-missing-dates/21924845#21924845

Maybe stems from:

```
In [284]: pd.datetools.parse(' ')
Out[284]: datetime.datetime(2014, 2, 20, 0, 0)
```



Discussion:

Resolving patch:
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -167,6 +167,10 @@
     * dict, e.g. {'foo' : [1, 3]} -> parse columns 1, 3 as date and call result
       'foo'
 
+    If a column or index contains an unparseable date, the entire column or
+    index will be returned unaltered as an object data type. For non-standard
+    datetime parsing, use ``pd.to_datetime`` after ``pd.read_csv``
+
     Note: A fast-path exists for iso8601-formatted dates.
 infer_datetime_format : boolean, default False
     If True and parse_dates is enabled, pandas will attempt to infer the format


Test patch:
diff --git a/pandas/io/tests/test_date_converters.py b/pandas/io/tests/test_date_converters.py
--- a/pandas/io/tests/test_date_converters.py
+++ b/pandas/io/tests/test_date_converters.py
@@ -138,6 +138,19 @@ def date_parser(date, time):
                                names=['datetime', 'prn']))
         assert_frame_equal(df, df_correct)
 
+    def test_parse_date_column_with_empty_string(self):
+        # GH 6428
+        data = """case,opdate
+                  7,10/18/2006
+                  7,10/18/2008
+                  621, """
+        result = read_csv(StringIO(data), parse_dates=['opdate'])
+        expected_data = [[7, '10/18/2006'],
+                         [7, '10/18/2008'],
+                         [621, ' ']]
+        expected = DataFrame(expected_data, columns=['case', 'opdate'])
+        assert_frame_equal(result, expected)
+
 if __name__ == '__main__':
     nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
                    exit=False)
diff --git a/pandas/tseries/tests/test_timeseries.py b/pandas/tseries/tests/test_timeseries.py
--- a/pandas/tseries/tests/test_timeseries.py
+++ b/pandas/tseries/tests/test_timeseries.py
@@ -947,6 +947,18 @@ def test_to_datetime_on_datetime64_series(self):
         result = to_datetime(s)
         self.assertEqual(result[0], s[0])
 
+    def test_to_datetime_with_space_in_series(self):
+        # GH 6428
+        s = Series(['10/18/2006', '10/18/2008', ' '])
+        tm.assertRaises(ValueError, lambda: to_datetime(s, errors='raise'))
+        result_coerce = to_datetime(s, errors='coerce')
+        expected_coerce = Series([datetime(2006, 10, 18),
+                                  datetime(2008, 10, 18),
+                                  pd.NaT])
+        tm.assert_series_equal(result_coerce, expected_coerce)
+        result_ignore = to_datetime(s, errors='ignore')
+        tm.assert_series_equal(result_ignore, s)
+
     def test_to_datetime_with_apply(self):
         # this is only locale tested with US/None locales
         _skip_if_has_locale()