This commit is contained in:
Elijah McMorris 2023-06-29 20:28:46 +00:00
parent 0de1bcb725
commit 41bd1e8fe7
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
3 changed files with 52 additions and 30 deletions

View file

@ -36,24 +36,29 @@ use util::*;
// }
// }
fn main() {
let read = Ark::new(Source::Read, Ticker::ARKK, None)
.unwrap()
.collect()
.unwrap();
println!("{:#?}", read.dtypes());
println!("{:#?}", read);
let api = Ark::new(Source::ApiFull, Ticker::ARKK, None)
.unwrap()
.collect()
.unwrap();
println!("{:#?}", api);
// let ark = Ark::new(Source::Ark, Ticker::ARKK, None)
fn main() -> Result<(), Box<dyn std::error::Error>> {
// let csv = Ark::merge_old_csv_to_parquet(Ticker::ARKK, None)
// .unwrap()
// .format()
// .unwrap()
// .write_parquet()
// .unwrap()
// .collect()
// .unwrap();
// println!("{:#?}", csv);
let read = Ark::new(Source::Read, Ticker::ARKK, None)?.collect()?;
println!("{:#?}", read.dtypes());
println!("{:#?}", read.get_column_names());
println!("{:#?}", read);
// let api = Ark::new(Source::ApiFull, Ticker::ARKK, None)
// .unwrap()
// .collect()
// .unwrap();
// println!("{:#?}", api);
// let ark = Ark::new(Source::Ark, Ticker::ARKK, None)?.collect()?;
// println!("{:#?}", ark);
// let ark = Ark::new(Source::Ark, Ticker::ARKVC, None)
@ -61,4 +66,5 @@ fn main() {
// .collect()
// .unwrap();
// println!("{:#?}", ark);
Ok(())
}

View file

@ -1,14 +1,14 @@
use chrono::NaiveDate;
use glob::glob;
use polars::datatypes::DataType;
use polars::lazy::dsl::StrptimeOptions;
use polars::prelude::*;
use polars::prelude::{DataFrame, StrptimeOptions, UniqueKeepStrategy};
use reqwest::blocking::Client;
use serde_json::Value;
use std::error::Error;
use std::fs::{create_dir_all, File};
use std::io::Cursor;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::result::Result;
use strum_macros::EnumIter;
@ -249,21 +249,38 @@ impl Ark {
if df.get_column_names().contains(&"weight_rank") {
_ = df.drop_in_place("weight_rank");
}
let mut expressions: Vec<Expr> = vec![];
if df.get_column_names().contains(&"") {
let mut cols = df.get_column_names();
cols.retain(|&item| !item.is_empty());
df = df.select(cols)?;
}
if !df.fields().contains(&Field::new("date", DataType::Date)) {
expressions.push(col("date").str().strptime(
DataType::Date,
StrptimeOptions {
format: Some("%m/%d/%Y".into()),
strict: false,
exact: true,
cache: true,
},
));
let date_format = |df: DataFrame, format: &str| -> Result<DataFrame, Box<dyn Error>> {
Ok(df
.lazy()
.with_column(col("date").str().strptime(
DataType::Date,
StrptimeOptions {
format: Some(format.into()),
strict: false,
exact: true,
cache: true,
},
))
.collect()?)
};
if let Ok(x) = date_format(df.clone(), "%m/%d/%Y") {
df = x
}
if let Ok(x) = date_format(df.clone(), "%Y/%m/%d") {
df = x
}
}
let mut expressions: Vec<Expr> = vec![];
if df.fields().contains(&Field::new("weight", DataType::Utf8)) {
expressions.push(
col("weight")

View file

@ -25,8 +25,7 @@ fn get_api_arkk() -> Result<(), Box<dyn Error>> {
"share_price",
"shares",
"ticker",
"weight",
"weight_rank"
"weight"
]
);
Ok(())