首页 > 其他分享 >DuckDB - Study Notes 8

DuckDB - Study Notes 8

时间:2025-01-15 21:12:26浏览次数:1  
标签:22 Study Domestic Cat Mix DuckDB 2023 November Notes

 

 

 

 

 

pi_relation = duckdb.sql("SELECT pi() AS pi")
type(pi_relation)

# duckdb.duckdb.DuckDBPyRelation

 

pi_relation.show()

 

┌───────────────────┐
│        pi         │
│      double       │
├───────────────────┤
│ 3.141592653589793 │
└───────────────────┘

 

pi_relation

 

┌───────────────────┐
│        pi         │
│      double       │
├───────────────────┤
│ 3.141592653589793 │
└───────────────────┘

 

duckdb.sql(
    """
    SELECT *
    FROM read_csv('data/C08/Seattle_Pet_Licenses.csv')
    """
)

As our call to duckdb.sql() is the only expression in this cell, it is evaluated, and the resulting relation object is displayed:

┌────────────────────┬────────────────┬───────────────┬─────────┬──────────────────────┬─────────────────┬──────────┐
│ License Issue Date │ License Number │ Animal's Name │ Species │    Primary Breed     │ Secondary Breed │ ZIP Code │
│      varchar       │    varchar     │    varchar    │ varchar │       varchar        │     varchar     │ varchar  │
├────────────────────┼────────────────┼───────────────┼─────────┼──────────────────────┼─────────────────┼──────────┤
│ December 18 2015   │ S107948        │ Zen           │ Cat     │ Domestic Longhair    │ Mix             │ 98117    │
│ June 14 2016       │ S116503        │ Misty         │ Cat     │ Siberian             │ NULL            │ 98117    │
│ August 04 2016     │ S119301        │ Lyra          │ Cat     │ Mix                  │ NULL            │ 98121    │
│ February 13 2019   │ 962273         │ Veronica      │ Cat     │ Domestic Longhair    │ NULL            │ 98107    │
│ August 10 2019     │ S133113        │ Spider        │ Cat     │ LaPerm               │ NULL            │ 98115    │
│ November 21 2019   │ 8002549        │ Maxx          │ Cat     │ American Shorthair   │ NULL            │ 98125    │
│ May 24 2020        │ S142869        │ Mickey        │ Cat     │ Domestic Longhair    │ NULL            │ 98126    │
│ July 03 2020       │ S112835        │ Diamond       │ Cat     │ Domestic Shorthair   │ Mix             │ 98103    │
│ July 21 2020       │ S131986        │ Nacho         │ Cat     │ Domestic Shorthair   │ Mix             │ 98126    │
│ August 18 2020     │ 8019541        │ Gracie        │ Cat     │ Domestic Medium Hair │ Mix             │ 98133    │
│       ·            │    ·           │   ·           │  ·      │         ·            │  ·              │   ·      │
│       ·            │    ·           │   ·           │  ·      │         ·            │  ·              │   ·      │
│       ·            │    ·           │   ·           │  ·      │         ·            │  ·              │   ·      │
│ November 22 2023   │ S148106        │ Gibbs         │ Cat     │ Domestic Shorthair   │ Mix             │ 98116    │
│ November 22 2023   │ 8042587        │ Barry         │ Cat     │ American Shorthair   │ Mix             │ 98109    │
│ November 22 2023   │ 8042588        │ Penny         │ Cat     │ American Shorthair   │ Mix             │ 98109    │
│ November 22 2023   │ 8050533        │ Sabine        │ Cat     │ Domestic Medium Hair │ York Chocolate  │ 98144    │
│ November 22 2023   │ 8050534        │ Milo          │ Cat     │ Domestic Medium Hair │ Mix             │ 98144    │
│ November 22 2023   │ S137987        │ Spike         │ Cat     │ Domestic Medium Hair │ NULL            │ 98117    │
│ November 22 2023   │ S137986        │ Scout         │ Cat     │ Domestic Shorthair   │ NULL            │ 98117    │
│ November 22 2023   │ 8013084        │ Honeybee      │ Cat     │ American Shorthair   │ Mix             │ 98106    │
│ November 22 2023   │ S157559        │ Bug           │ Cat     │ Ragdoll              │ Siamese         │ 98144    │
│ November 22 2023   │ 8042668        │ Beerus        │ Cat     │ Domestic Shorthair   │ Mix             │ 98125    │
├────────────────────┴────────────────┴───────────────┴─────────┴──────────────────────┴─────────────────┴──────────┤
│ ? rows (>9999 rows, 20 shown)                                                                           7 columns │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

 

 

pets_csv_relation = duckdb.read_csv(
    "data/C08/Seattle_Pet_Licenses.csv"
)

 

pets_csv_relation.types

# [VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR]

 

 

标签:22,Study,Domestic,Cat,Mix,DuckDB,2023,November,Notes
From: https://www.cnblogs.com/zhangzhihui/p/18673697

相关文章

  • Markdown-study
    Markdown-study标题一级标题一个#二级标题两个#三级标题三个#字体粗体左右两个*斜体左右一个*横线左右两个~引用一个>+空格即可分割线三个-或者三个*图片![图片](路径)超链接点击跳转列表数字+空格B减-+空格B表格右键插入即可......
  • DuckDB - Study Notes 6
      DuckDB’snesteddatatypes:LIST, MAP,andSTRUCT. DSELECT[7,8,9]ASlist_int;┌───────────┐│list_int││int32[]│├───────────┤│[7,8,9]│└───────────┘ DSELECT['Quantumof......
  • DuckDB - Study Notes 5
     DSELECT*FROMduckdb_extensions();┌──────────────────┬─────────┬───────────┬──────────────┬───┬───────────────────┬───────────────────┬───────......
  • DuckDB:星号(*)表达式完整指南
    本文介绍DuckDB星号的用法,尤其是与其他数据库不同的用法,掌握它可以快速帮你选择和转换列。常规用法首先我们介绍星号表达式的常规用法,这与其他数据库功能一样。#选择from子句中所有列SELECT*FROMtable_name;#计算表中的行数,DuckDB支持省略*号SELECTcount(......
  • 安装 php 开发环境(基于 php study)
    目录安装 php 开发环境(基于 phpstudy)创建简单博客示例代码下载 phpstudy:可以从官网(xp.cn)下载,也可以在内网(如提到的 6.100)下载,或者使用已提供的安装包。安装过程:双击安装包,若电脑有 D 盘且无特殊需求,默认安装路径为 D:\phpstudy;若没有 D 盘,则需将路径......
  • DuckDB - Study Notes 4
         blockrangeindex,BRIN   adaptiveradixtree,ART Todownloadthenecessarydatasetforthisproject,pleasefollowtheseinstructions:1.Gotohttps://www.kaggle.com/datasets/mohamedbakhet/amazon-books-reviews.2.ClickontheDown......
  • DuckDB - Study Notes 3
        DataWrangling CREATEORREPLACETABLEweb_log_text(raw_textVARCHAR); COPYweb_log_textFROM'access.log'(DELIM''); SELECTregexp_extract(raw_text,'^[0-9\.]*')ASclient_ipFROMweb_log_textLIM......
  • @Notes:将整数转为excel对应的列标
    /**@Notes:将整数转为excel对应的列标@Functionint_to_chr@param$index@param$start@returnstring@Authorgxk@Date2024/10/16@Time17:53*/functionint_to_chr($index,$start=65){$str='';if($index>=26){weibow.com$les=$index%26;$index......
  • DDR Study - LPDDR4 BRC RBC QoS
    参考来源:LPDRAM4/4XPerformanceTweaksBankrotation/interleaving基于DRAM的BANK-ROW-COLUMN结构,以及访问同一Bank内不同Row时需要的Pre-Charge+Active行为,对两种Address组成进行分析:Bank-Row-ColumnAddressScheme(BRC)这种结构下,MSB是CS+BankGroup,LSB是Colu......
  • notes for linear algebra
    Diagonalization$1\le\dim(E_{\lambda})\le$multiplicityof\(\lambda\).Assume\(T\)splits,itisdiagonalizableiff$\dim(E_{\lambda})=$multiplicityof\(\lambda\)forall\(\lambda\).Cayley-HamiltonTheoremLemma1.Let\(W\)be......