def __init__(self, num_notes=20, starting_note="0"):
     """ __init__ """
     self.res_path = str(Path("components/res/"))
     self.data_table = Table.read_table(self.res_path +
                                        "/probability_table.csv")
     self.notes = self.data_table.column("octave")
     self.num_notes = num_notes
     self.starting_note = starting_note
Exemplo n.º 2
0
Arquivo: b2.py Projeto: yifanwu/b2
 def from_file(self, filepath_or_buffer, *args, **vargs):
     try:
         table = Table.read_table(filepath_or_buffer, *args, **vargs)
         df_name = find_name()
         return self.create_with_table_wrap(table, df_name)
     except FileNotFoundError:
         red_print(f"File {filepath_or_buffer} does not exist!")
     except UserError as err:
         red_print(err)
Exemplo n.º 3
0
    #set the table name here
    table_name = "ahlxgcalc"+str(i)

    try:
        create_table = '''CREATE TABLE %s ( 
            XLocation INT,
            YLocation INT,
            xG FLOAT )'''
        cursor.execute(create_table % table_name)
        connection.commit()
    except (Exception, psycopg2.DatabaseError) as error :
        print ("Error while creating PostgreSQL table", error)

# events is a csv file containing all X Location and Y Location values
# based on the database it will calculate an xG value
events = Table.read_table("input_simple.csv")

#populate each ahlxgCalc table w/ datapoints from CSV
for i in range(0,5):
    #set the table name here
    table_name = "ahlxgcalc"+str(i)
    print("Populating %s with all x,y points" % table_name)
    for event_row in events.rows:
        values = """INSERT INTO %s (XLocation, YLocation) VALUES (%%s,%%s)"""
        cursor.execute(values % table_name, [int(event_row[0]),int(event_row[1])])

#variable sized smoothing swaths for different strengths
smoothing_swath = [5,30,39,28,8]

for i in range(0,5):
    #set the table name here
Exemplo n.º 4
0
 def read_table(self, *args, **kwargs):
     return self._fix_(Table.read_table(*args, **kwargs))
Exemplo n.º 5
0
# Importing Data Science Libraries

import pandas as pd
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')

get_ipython().run_line_magic('matplotlib', 'inline')
from datascience import Table
from datascience.predicates import are
from datascience.util import *

# Importing Data as Table

general_tbl = Table.read_table("DemogFinalProject.csv")
general_tbl = general_tbl.drop("BPL", "BPLD", "YRIMMIG")
general_tbl

# Creating Tables Filtered by Year and Origin, Grouped By Metropolitan Area

grouped2000 = general_tbl.where("YEAR", are.equal_to(2000)).group("MET2013")
grouped2000 = grouped2000.where("MET2013", are.not_equal_to(0))
num_hispanic2000 = make_array()
af_wage2000 = make_array()
for i in np.arange(grouped2000.num_rows):
    tbl_specific = general_tbl.where(
        "MET2013", are.equal_to(grouped2000.column("MET2013").item(i)))
    num_hispanic2000 = np.append(
        num_hispanic2000,
        (tbl_specific.where("HISPAN", are.not_equal_to(0)).num_rows) /
Exemplo n.º 6
0
from flask import Flask, jsonify,request

from datascience import Table
from intervaltree import Interval, IntervalTree

prefixcode = ''

t = Table.read_table('CourseWhere.csv')
trees = {day:IntervalTree() for day in ['M','T','W','R','F','S']}
for row in t.rows:
    for day in row[5]:
        trees[day][row[6]:row[7]] = row

room_table = t.group('Building',collect=set).select(['Building','Facility set'])
room_list = {building.lower():rooms for building,rooms in zip(room_table['Building'],room_table['Facility set'])}


app = Flask(__name__)

def class_to_dict(clas):
    convert = lambda x: x if isinstance(x,str) else int(x)
    return {label:convert(v) for label,v in zip(t.column_labels,clas)}

@app.route(prefixcode+'/rooms/<building>/<room>')
def get_room(building,room):
    weekday = request.args.get('day', 'M')
    if weekday not in "MTWRFS":
        weekday = 'M'
    values = [class_to_dict(v) for v in t.where('Building',building).where('Room',room).rows]
    values = [v for v in values if weekday in v['Days']]
    values = sorted(values,key=lambda x:x['Start'])