-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpandas_sample.bs
42 lines (36 loc) · 1.12 KB
/
pandas_sample.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import panda_branes;
let data := new Data { name := "job_data" };
let cols := columns(data);
println("Initial columns");
println(cols);
println(" ");
// drop columns
// NOTE: Untitled:0 is the index column automatically created by pandas
// We can't drop it for some reason :|
let drop_list := "[Job Title, Job Description]";
let data_dropped := drop_columns(data, [drop_list]);
let cols_after_drop := columns(data_dropped);
println("Columns after drop");
println(cols_after_drop);
println(" ");
// rename columns
let rename_dict := "{\"Salary Estimate\": \"s_est\"}";
let renamed := rename_column(data_dropped, [rename_dict]);
let cols_after_rename := columns(renamed);
println("Columns after rename");
println(cols_after_rename);
println(" ");
// get column
let column := "Location";
let col := get_column(renamed, [column]);
println("Column");
println(col);
println(" ");
// exec func
let custom := "df['City'] = df['Location'].apply(lambda x: x.split(',')[0])";
let after_exec := exec_custom(renamed, [custom]);
let cols_after_exec := columns(after_exec);
println("Columns after exec");
println(cols_after_exec);
println(" ");
return;