我尝试使用matplotlib.finance从yahoo finance下载一些数据。
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <iterator>
using namespace std;
struct Record {
string bar_code;
double unit_price;
int inventory_quantity;
string item_description;
friend ostream& operator<<(ostream&, Record const&);
};
vector<Record> ReadDataFile();
int main() {
auto data = ReadDataFile();
copy(data.begin(), data.end(), ostream_iterator<Record>(std::cout, "\n"));
}
vector<Record> ReadDataFile() {
vector<Record> data;
ifstream inputfile("C:\\Temp\\data.txt");
size_t linenumber = 0;
string line;
while (getline(inputfile, line)) {
linenumber += 1;
Record r;
istringstream iss(line);
if (iss >> r.bar_code >> r.item_description >> r.inventory_quantity >> r.unit_price)
data.push_back(r);
else
throw runtime_error("Parse error in line #" + to_string(linenumber) + " '" + line + "'");
}
return data;
}
ostream& operator<<(ostream& os, Record const& r) {
return os << r.bar_code << " " << r.item_description << " " << r.inventory_quantity << " " << r.unit_price;
}
结果类似于
from matplotlib.finance import quotes_historical_yahoo
from datetime import date
import pandas as pd
import numpy as np
%matplotlib inline
today=date.today()
start=(today.year-1,today.month,today.day)
quotes=quotes_historical_yahoo('AXP',start,today)
df=pd.DataFrame(quotes,columns=['Date','Open','High','Low','Close','Vol'])
df
我知道第一列应该是日期,但我不知道如何从中获取日期时间。如何处理此列以使其像 Date Open High Low Close Vol
0 735536 87.376999 87.524947 88.264678 86.992340 5069300
1 735537 88.708520 88.718378 89.359479 88.146325 6848600
2 735540 89.083316 89.606057 89.961129 88.984686 3707900
?
答案 0 :(得分:0)
我自己解决,关键是using (var transaction = client.BeginTransaction())
{
manifest.Users = client.Cypher
.Merge("(n:User { Id: '8be0b8fd-c433-44d3-a7e2-3f0d1a03fefa'}) " +
"ON CREATE " +
"SET n = { " +
"Id: '8be0b8fd-c433-44d3-a7e2-3f0d1a03fefa', " +
"UserName: 'test.user', " +
"Name: 'Test User', " +
"Active: true " +
"} " +
"ON MATCH " +
"SET n = { " +
"Id: '8be0b8fd-c433-44d3-a7e2-3f0d1a03fefa', " +
"UserName: 'test.user', " +
"Name: 'Test User', " +
"Active: true " +
"}")
.Return(n => n.As<User>())
.Results
.ToList();
transaction.Commit();
}
+ date.fromordinal()
date.strftime(x,'%Y-%m-%d')