I am currently trying to merge two csv files using the following code:
import pandas as pd
data1 = pd.read_csv("QLD.csv")
data2 = pd.read_csv("VIC.csv")
result = pd.merge(data1[['REGION', 'TOTALDEMAND', 'RRP']], data2[['REGION', 'TOTALDEMAND', 'RRP']], on='SETTLEMENTDATE')
result.to_csv("masterfile.csv", index=False)
This is what the head of each of my csv files look like:
When I run my code I receive this error:
Traceback (most recent call last):
File "/Users/george/Desktop/collate/asdas.py", line 4, in <module>
result = pd.merge(data1[['REGION', 'TOTALDEMAND', 'RRP']], data2[['REGION', 'TOTALDEMAND', 'RRP']], on='SETTLEMENTDATE')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/reshape/merge.py", line 61, in merge
validate=validate)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/reshape/merge.py", line 551, in __init__
self.join_names) = self._get_merge_keys()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/reshape/merge.py", line 857, in _get_merge_keys
rk, stacklevel=stacklevel))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/generic.py", line 1382, in _get_label_or_level_values
raise KeyError(key)
KeyError: 'SETTLEMENTDATE'
Any idea what's going wrong? Thanks