- 博客(17)
- 收藏
- 关注
原创 将txt读取 并转换为dataframe
f = open("interest.txt","r",encoding='utf-8') #设置文件对象 result=[] for line in f.readlines():#readlines以列表输出文件内容 line=line.strip().split("\t") result.append(line) f.close() #将文件关闭 result=pd.DataFrame(result).dropna(axis=0) ...
2020-12-15 13:32:41
4376
原创 将dataframe转为list
要处理的dataframe >>>corr_result 基金代码 159801.0 159804.0 159805.0 ... 515960.0 515980.0 515990.0 基金代码 ... 159801.0 1.000000 0.865664 0.861470 ... 0.713277 0.939222 0.754
2020-12-10 20:24:37
1438
原创 SKLEARN NEAREST NEIGHBOR & KNeighborsClassifier
ALGORITHM-1NN from sklearn.neighbors import NearestNeighbors import numpy as np X = np.array([[-1, -1], [1, 1], [-3, -2], [1, 1], [2, 1], [3, 2]]) nbrs = NearestNeighbors(n_neighbors=2, algorithm='ball_tree').fit(X) distances, indices = nbrs.kneighbors(X)
2020-12-10 11:29:58
255
原创 根据multiindex生成面板数据
data=data.set_index(['日期','基金代码'])['单位净值'] data=data.unstack()
2020-12-08 12:07:05
196
原创 读取csv时将日期设为timestamp
data = pd.read_csv('etf18012009.csv',parse_dates = ['日期'])
2020-12-08 12:02:52
729
原创 第五章课后题
PRAC 1 // prac1.cpp #include<iostream> int small; int large; int result; int i; int main() { using namespace std; cout << "Enter a samll number: "; cin >> small; cout << "Enter a large number: "; cin >> large; for (i=sma
2020-12-08 12:00:33
408
原创 第6章 分支语句和逻辑运算符
6.1 if语句 程序清单6.1 if.cpp // if.cpp -- using the if statement #include<iostream> int main() { using std::cin; using std::cout; using std::endl; char ch; int space = 0; int total = 0; cin.get(ch); while (ch!='.') //quit at end of sentence {
2020-12-08 12:00:22
213
原创 第四章 课后题
Prac 1 // prac1.cpp #include<iostream> struct aaa { char first_name[20]; char last_name[20]; char grade; int Age; } ; int main() { using namespace std; aaa * b = new aaa; cout << "What is your first name?"; cin.get(b->first_n
2020-07-11 11:46:12
272
原创 第5章 循环和关系表达式
5.1 for循环 程序清单5.1 forloop.cpp // forloop.cpp -- introducing the for loop #include<iostream> int main() { using namespace std; int i; // create a counter for (i = 0; i < 5; i++) cout << "C++ knows loops.\n"; cout << "C++ knows
2020-07-11 11:44:11
352
原创 Chapter3 课后题
PRAC 1 // prac1.cpp #include<iostream> const int trans = 100; int main() { using namespace std; cout << "Enter your height:___\b\b\b"; int height; cin >> height; double theight = double(height)/ trans; cout << "Your height is
2020-07-04 19:28:02
162
原创 第四章 复合类型
4.1 数组 数组可以存储60个int类型的值、12个short值或365个float值。 要创建数组,可使用声明语句。数组声明应指出以下三点: 存储在每个元素中的值的类型; 数组名; 数组中的元素数; short months[12]; // creats array of 12 short 程序清单 4.1 arrayone.cpp // arrayone.cpp -- small arrays fo integers #include<iostream> int main() {
2020-07-04 19:27:37
344
原创 第三章 数据处理
3.1 简单变量 3.1.1 变量名 在名称中只能使用字母字符、数字和下划线 名称的第一个字符不能是数字 区分大小写 不能使用关键字 int _Mystar3; //valid but reserved --starts with underscore int __foold; // valid but reserved --starts with two underscore 3.1.2 整型 3.1.3 整形short、int、long和long long short至少16位 int至少和sho
2020-06-27 19:38:53
648
原创 Chapter2 练习
PRAC 1 //prac1 #include<iostream> int main() { using namespace std; cout << "My name is Bing." << endl; cout << "I live in Chengdu" << endl; return 0; } My name is Bing. I live in Chengdu PRAC 2 // prac2.cpp #include&
2020-06-26 18:10:41
108
原创 C++ Primer Plus 第2章 开始学习C++
2.1 进入C++ 程序清单2.1 myfirst.cpp // my first.cpp -- display a message #include<iostream> // a PREPROCESSOR directive int main() // function header { //start of function body using namespace std; //make definitions vi
2020-06-26 17:38:51
547
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅
1