Aug-07-2017, 06:14 PM
my question here
Hi,
I have a huge problem and i cant solve it on my own. I'm sure it is simple but
I cant get it.
You need these 2 files for the short script: www.file-upload.net/download-12647206/djia.csv.html...#
and
www.file-upload.net/download-12647207/PreisMoatStanley2013.dat.html...#
The problem is to get the index to Date. My index is always empty
Empty DataFrame
Columns: [DJIAClose, GoogleWE, debt, Close]
Index: []
How it should looks like:
Out[8]:
DJIAClose GoogleWE debt Close
Date
2004-01-12 10485.18 2004-01-10 0.21 10485.2
2004-01-20 10528.66 2004-01-17 0.21 10528.7
2004-01-26 10702.51 2004-01-24 0.21 10702.5
Maybe someone have any idea to help me.
Thanks
Hi,
I have a huge problem and i cant solve it on my own. I'm sure it is simple but
I cant get it.
You need these 2 files for the short script: www.file-upload.net/download-12647206/djia.csv.html...#
and
www.file-upload.net/download-12647207/PreisMoatStanley2013.dat.html...#
The problem is to get the index to Date. My index is always empty
import pandas as pd import numpy as np import datetime as dt import matplotlib.pyplot as plt import pandas_datareader.data as web import datetime paper = pd.read_csv('PreisMoatStanley2013.dat', delimiter = ' ', parse_dates=[0,1,100,101]) data = pd.DataFrame({'GoogleWE': paper['Google End Date'], 'debt': paper['debt'].astype(np.float64), 'DJIADate': paper['DJIA Date'], 'DJIAClose': paper['DJIA Closing Price'] .astype(np.float64)}) data.set_index('DJIADate') print paper [:5] import quandl #api_key = open('quandl_key.txt','r').read() djia = pd.read_csv("djia.csv", index_col=0) print djia[:3] djia_closes = djia['Close'].reset_index() djia_closes.set_index('Date') print djia_closes[:3] #s152 data = pd.merge(data, djia_closes, left_on='DJIADate', right_on='Date') data.drop(['DJIADate'], inplace=True, axis=1) data = data.set_index('Date') # Problem seems to be here print data[:3]Shell message :
Empty DataFrame
Columns: [DJIAClose, GoogleWE, debt, Close]
Index: []
How it should looks like:
Out[8]:
DJIAClose GoogleWE debt Close
Date
2004-01-12 10485.18 2004-01-10 0.21 10485.2
2004-01-20 10528.66 2004-01-17 0.21 10528.7
2004-01-26 10702.51 2004-01-24 0.21 10702.5
Maybe someone have any idea to help me.
Thanks