This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID | Label | Level | Level ID | Value | |
---|---|---|---|---|---|
1 | A | HR | 1 | 20 | |
1 | B | IT | 1 | 30 | |
1 | C | Sales | 1 | 15 | |
1 | D | Finance | 1 | 35 | |
2 | A1 | HR | 2 | 10 | |
3 | A2 | HR | 2 | 5 | |
4 | A3 | HR | 2 | 5 | |
2 | B1 | IT | 2 | 15 | |
3 | B2 | IT | 2 | 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k = hs.hotkey.modal.new('ctrl-shift', 'n') | |
function k:entered() hs.alert'Virtual Numpad' end | |
function k:exited() hs.alert'Exit Virtual Numpad' end | |
k:bind('ctrl-shift', 'n', function() k:exit() end) | |
hs.fnutils.each({ | |
{ key='j', padkey='pad1'}, | |
{ key='k', padkey='pad2'}, | |
{ key='l', padkey='pad3'}, | |
{ key='u', padkey='pad4'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.read_csv("Global Temperature Anomalies.csv") | |
print(df.columns) | |
# parameter values | |
id_vars = ['Hemisphere', 'Year'] | |
cols_to_pivot = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', | |
'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'J-D', 'D-N', 'DJF', 'MAM', 'JJA', | |
'SON'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# append all DataFrames into one before writing to single table in Hyper | |
final_df = df1.append(df2).append(df3).reset_index(drop=True) | |
pantab.frames_to_hyper({"pokemon": final_df}, "hyper/all_pokemon_in_one.hyper") | |
# this produces the same result as above | |
pantab.frame_to_hyper(df1, "hyper/all_pokemon_append.hyper", table = "pokemon") | |
pantab.frame_to_hyper(df2, "hyper/all_pokemon_append.hyper", table = "pokemon", table_mode = "a") | |
pantab.frame_to_hyper(df3, "hyper/all_pokemon_append.hyper", table = "pokemon", table_mode = "a") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(pantab.frames_from_hyper("hyper/pokemon_public.hyper").keys()) | |
# dict_keys([TableName('public', 'pokemon')]) | |
print(pantab.frames_from_hyper("hyper/pokemon_extract.hyper").keys()) | |
# dict_keys([TableName('Extract', 'pokemon')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this errors out with message "HyperException: Specified table does not exist: pokemon." | |
pantab.frame_from_hyper("hyper/pokemon_extract.hyper", table = "pokemon") | |
# need to specify schema to read table from | |
pantab.frame_from_hyper("hyper/pokemon_extract.hyper", table = TableName("Extract", "pokemon")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# these two are equivalent | |
pantab.frame_from_hyper("hyper/pokemon_public.hyper", table = "pokemon") | |
pantab.frame_from_hyper("hyper/pokemon_public.hyper", table = TableName("public", "pokemon")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import pantab | |
from tableauhyperapi import TableName | |
df = pd.read_csv("data/starter_pokemon_grass.csv") | |
# save DataFrame output to .hyper file | |
pantab.frame_to_hyper(df, "hyper/pokemon_public.hyper", table = "pokemon") | |
# save to schema other than public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df1 = pd.read_csv("data/starter_pokemon_grass.csv") | |
df2 = pd.read_csv("data/starter_pokemon_fire.csv") | |
df3 = pd.read_csv("data/starter_pokemon_water.csv") | |
dict_df = {"grass": df1, "fire": df2, "water": df3} | |
pantab.frames_to_hyper(dict_df, "hyper/all_pokemon_separate.hyper") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from tableauhyperapi import HyperProcess, Telemetry, Connection, CreateMode, NOT_NULLABLE, NULLABLE, SqlType, \ | |
TableDefinition, Inserter, escape_name, escape_string_literal, HyperException, TableName | |
with HyperProcess(telemetry=Telemetry.DO_NOT_SEND_USAGE_DATA_TO_TABLEAU) as hyper: | |
print("starting up Hyper Process") | |
with Connection(hyper.endpoint, 'hyper/pokemon_hyper_api.hyper', CreateMode.CREATE_AND_REPLACE) as connection: | |
print("creating or replacing pokemon_hyper_api.hyper") | |
poke_table = TableDefinition(TableName('public','pokemon'), [ |
NewerOlder