
import pandas
from datetime import datetime

# Change source to smaller file.
data = pandas.read_csv("data/Residential_Water_Usage_Zip_Code_on_Top.csv")

# print(data["Date Text"].head())


first_date = data["Date Text"].values[0]
print(first_date)

# datetime.strptime(first_date, "%Y-%m-%d")
# datetime(2012, 3, 10, 0, 0)

# data.date = data.date.apply(lambda d: datetime.strptime(d, "%Y-%m-%d"))
# print(data.date.head())
# data.index = data.date
# print(data)

# print(data.ix[datetime(2012, 8, 19)])

# Remove date column
# data = data.drop(["date"], axis=1)
# print(data.columns)

# Determine what values are missing
# empty = data.apply(lambda col: pandas.isnull(col))


import pandas
from datetime import datetime

# Change source to smaller file.
data = pandas.read_csv("data/Residential_Water_Usage_Zip_Code_on_Top.csv",
                       parse_dates=[0], infer_datetime_format=True)
temp = pandas.DatetimeIndex(data["Date_Text"])
data["Month"] = temp.month
data["Year"] = temp.year
print(data)

# print(data["Date Text"].head())


# first_date = data["Date Text"].values[0]
# print(first_date)

# datetime.strptime(first_date, "%b-%Y")

# datetime(2012, 3, 10, 0, 0)

# data.date = data["Date Text"].apply(lambda d: datetime.strptime(d, "%b-%Y"))
# print(data.date.head())
# data.index = data.date
# print(data)

# print(data.ix[datetime(2012, 8, 19)])

# Remove date column
# data = data.drop(["date"], axis=1)
# print(data.columns)

# Determine what values are missing
# empty = data.apply(lambda col: pandas.isnull(col))

Add code to split month and year into new columns.
Add code to split month and year into new columns.

  
  import pandas
  from datetime import datetime
  
  # Change source to smaller file.
- data = pandas.read_csv("data/Residential_Water_Usage_Zip_Code_on_Top.csv")
+ data = pandas.read_csv("data/Residential_Water_Usage_Zip_Code_on_Top.csv",
+                        parse_dates=[0], infer_datetime_format=True)
+ temp = pandas.DatetimeIndex(data["Date_Text"])
+ data["Month"] = temp.month
+ data["Year"] = temp.year
+ print(data)
  
  # print(data["Date Text"].head())
  
  
- first_date = data["Date Text"].values[0]
+ # first_date = data["Date Text"].values[0]
- print(first_date)
+ # print(first_date)
  
- # datetime.strptime(first_date, "%Y-%m-%d")
+ # datetime.strptime(first_date, "%b-%Y")
+ 
  # datetime(2012, 3, 10, 0, 0)
  
- # data.date = data.date.apply(lambda d: datetime.strptime(d, "%Y-%m-%d"))
+ # data.date = data["Date Text"].apply(lambda d: datetime.strptime(d, "%b-%Y"))
  # print(data.date.head())
  # data.index = data.date
  # print(data)
  
  # print(data.ix[datetime(2012, 8, 19)])
  
  # Remove date column
  # data = data.drop(["date"], axis=1)
  # print(data.columns)
  
  # Determine what values are missing
  # empty = data.apply(lambda col: pandas.isnull(col))
  
Add code to split month and year into new columns.
## Code Before:

import pandas
from datetime import datetime

# Change source to smaller file.
data = pandas.read_csv("data/Residential_Water_Usage_Zip_Code_on_Top.csv")

# print(data["Date Text"].head())


first_date = data["Date Text"].values[0]
print(first_date)

# datetime.strptime(first_date, "%Y-%m-%d")
# datetime(2012, 3, 10, 0, 0)

# data.date = data.date.apply(lambda d: datetime.strptime(d, "%Y-%m-%d"))
# print(data.date.head())
# data.index = data.date
# print(data)

# print(data.ix[datetime(2012, 8, 19)])

# Remove date column
# data = data.drop(["date"], axis=1)
# print(data.columns)

# Determine what values are missing
# empty = data.apply(lambda col: pandas.isnull(col))

## Instruction:
Add code to split month and year into new columns.
## Code After:

import pandas
from datetime import datetime

# Change source to smaller file.
data = pandas.read_csv("data/Residential_Water_Usage_Zip_Code_on_Top.csv",
                       parse_dates=[0], infer_datetime_format=True)
temp = pandas.DatetimeIndex(data["Date_Text"])
data["Month"] = temp.month
data["Year"] = temp.year
print(data)

# print(data["Date Text"].head())


# first_date = data["Date Text"].values[0]
# print(first_date)

# datetime.strptime(first_date, "%b-%Y")

# datetime(2012, 3, 10, 0, 0)

# data.date = data["Date Text"].apply(lambda d: datetime.strptime(d, "%b-%Y"))
# print(data.date.head())
# data.index = data.date
# print(data)

# print(data.ix[datetime(2012, 8, 19)])

# Remove date column
# data = data.drop(["date"], axis=1)
# print(data.columns)

# Determine what values are missing
# empty = data.apply(lambda col: pandas.isnull(col))
