I did a transpose of my dataframe and now I have headers that consist of numbers from 1 - 21384.
df_final.columns.values
Out[39]: array([ 0, 1, 2, ..., 21382, 21383, 21384], dtype=int64)
0 1 2 3 ... 21381 21382 \
qyear 2011Q1 2012Q1 2013Q1 2011Q1 ... 2013Q1 2011Q1
RCFD3531 0 0 0 0 ... 0 0
RCFD3532 0 0 0 0 ... 0 0
RCFD3533 0 0 0 0 ... 0 0
RCFD3541 0 0 0 0 ... 0 0
Is there a way to eliminate these headers and replace them with row #1? Or, perhaps ignore them? Or maybe update them based on row #1? The actual headers that I want to use are in the row named 'qyear':
qyear 2011Q1 2012Q1 2013Q1 2011Q1 ... 2013Q1 2011Q1
Basically, I want to do a merge, and it's not working.
df_final = pd.merge(df_final, df_list, left_on='qyear', right_on='IDRSSD_ID', how='inner')
Traceback (most recent call last):
File "<ipython-input-42-324d32761a8c>", line 1, in <module>
df_final = pd.merge(df_final, df_list, left_on='qyear', right_on='IDRSSD_ID', how='inner')
File "C:\Users\ryans\Anaconda3\lib\site-packages\pandas\core\reshape\merge.py", line 87, in merge
validate=validate,
File "C:\Users\ryans\Anaconda3\lib\site-packages\pandas\core\reshape\merge.py", line 652, in __init__
) = self._get_merge_keys()
File "C:\Users\ryans\Anaconda3\lib\site-packages\pandas\core\reshape\merge.py", line 1018, in _get_merge_keys
left_keys.append(left._get_label_or_level_values(lk))
File "C:\Users\ryans\Anaconda3\lib\site-packages\pandas\core\generic.py", line 1563, in _get_label_or_level_values
raise KeyError(key)
KeyError: 'qyear'