728x90

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ 128

[Python] Pandas Dataframe ๊ธฐ๋ณธ (๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ/์ €์žฅํ•˜๊ธฐ, ๋ฐ์ดํ„ฐ ๊ฐœ์ˆ˜ ๊ตฌํ•˜๊ธฐ, ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„ ์—ฐ๊ฒฐํ•˜๊ธฐ, column ๋ชฉ๋ก ํ™•์ธ, pd.Series value_counts๋กœ ์—ด์˜ value ํ™•์ธํ•˜๊ธฐ)

pandas ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ - csv ํ˜•์‹ ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ import pandas as pd df = pd.read_csv('ํŒŒ์ผ๋ช….csv') # csvํŒŒ์ผํ˜•์‹์€ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ถˆ๋Ÿฌ์™€์ง - ํƒญ์œผ๋กœ ๋ถ„๋ฆฌ๋œ txt ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ import pandas as pd df= pd.read_csv('ํŒŒ์ผ๋ช….txt', delimiter = '\t') # ํƒญ์œผ๋กœ ๋ถ„๋ฆฌ๋œ txt(tsv ํ˜•์‹๋„ ๊ฐ€๋Šฅ) ๋ถˆ๋Ÿฌ์˜ค๊ธฐ - ๊ณต๋ฐฑ์œผ๋กœ ๋ถ„๋ฆฌ๋œ ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ import pandas as pd df = pd.read_csv(‘ํŒŒ์ผ๋ช….ํ™•์žฅ์ž’, delimiter = ' ') # ๊ณต๋ฐฑ์œผ๋กœ ๋ถ„๋ฆฌ๋œ ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ Dataframe์˜ data ๊ฐœ์ˆ˜ ์„ธ๊ธฐ print(len(df.index)) print(df.shape[0]) print(len(df))..

[PostgreSQL] Python์—์„œ PostgreSQL ์ ‘์†ํ•˜๊ธฐ, python์—์„œ SQL ์ฟผ๋ฆฌ๋ฌธ ์‹คํ–‰ํ•˜๊ธฐ + ์ฟผ๋ฆฌ ์‹คํ–‰ ๊ฒฐ๊ณผ ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„์œผ๋กœ ๋งŒ๋“ค๊ธฐ

PostgreSQL ์„œ๋ฒ„์— ์ ‘์†ํ•˜๊ธฐ psycopg2 ์„ค์น˜ import psycopg2 conn_string = "host = 'localhost' dbname = 'db๋ช…' user = 'user๋ช…' password = 'ํŒจ์Šค์›Œ๋“œ'" conn = psycopg2.connect(conn_string) cur = conn.cursor() ์œ„์˜ ์ฝ”๋“œ ์‹คํ–‰ ํ›„ SQL ์ฟผ๋ฆฌ๋ฅผ ํŒŒ์ด์ฌ์œผ๋กœ ์‹คํ–‰ ๊ฐ€๋Šฅ import pandas as pd cur.execute("์ฟผ๋ฆฌ๋ฌธ") # ์˜ˆ์‹œ # cur.execute("SELECT * FROM [DB๋ช…];") result = cur.fetchall() # result์— ๊ฒฐ๊ณผ ์ €์žฅ # ์ฟผ๋ฆฌ๋ฌธ ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ pandas dataframe ํ˜•์‹์œผ๋กœ ๋งŒ๋“ค๊ธฐ my_df = pd.DataFra..

[PostgreSQL] PostgreSQL์˜ GUI ํˆด pgAdmin ์‚ฌ์šฉ

sql์„ ์ด์šฉํ•œ ๋ฐ๋ฒ ๊ด€๋ฆฌ ์‹œ csv๋‚˜ ๋‹ค๋ฅธ ํŒŒ์ผ ํ˜•์‹์œผ๋กœ export/import ๋ฅผ ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒŒ ๊ฐ€์žฅ ํŽธ๋ฆฌํ•จ ์ €์žฅํ•˜๊ณ  ์‹ถ์€ schemas table ์„ ํƒ ํ›„ Tools -> Import/Export ์„ ํƒ export ํ›„ ํŒŒ์ผ ์ด๋ฆ„ .csv๋กœ ๋ฐ”๊พธ๋ฉด csv๋กœ ์ €์žฅ๋จ

[PostgreSQL] ๋Œ€์šฉ๋Ÿ‰ .sql ๋คํ”„ ํŒŒ์ผ ๋ณต์›ํ•˜๊ธฐ (์œˆ๋„์šฐ ๊ธฐ๋ฐ˜)

๋Œ€์šฉ๋Ÿ‰ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๊ฒฝ์šฐ ๋คํ”„ ํŒŒ์ผ๋กœ ์ €์žฅ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ ๋งŽ์Œ. ๋‚ด๊ฐ€ ์‚ฌ์šฉํ–ˆ๋˜ STRING Biological Pathway database์˜ ๊ฒฝ์šฐ ๋คํ”„ํŒŒ์ผ์˜ ํฌ๊ธฐ๋„ 83GB ๋ผ ์ƒ๋‹นํžˆ ์ปธ์Œ... ์•„๋ฌดํŠผ ์ด ๋ช…๋ น ํ•˜๋‚˜๋ฉด ๋Œ€์šฉ๋Ÿ‰ DB ๋คํ”„ํŒŒ์ผ ๋ณต์› ๊ฐ€๋Šฅํ•˜๋‹ค. ํ•˜์ง€๋งŒ ์€๊ทผ ์‹œ๊ฐ„ ๊ฑธ๋ฆฐ๋‹ค๋Š”์  ใ…Žใ……ใ…Ž cmd ์ฐฝ ์—ด๊ณ  ์ž…๋ ฅ psql -U {์œ ์ €๋„ค์ž„} -d {๋คํ”„ํŒŒ์ผ ํ’€๊ณ  ์‹ถ์€ DB๋ช…} -a -f {๋คํ”„ํŒŒ์ผ์œ„์น˜} EX) psql -U postgres -d [mydbname] -a -f C:\Users\Downloads\[ํŒŒ์ผ๋ช…].sql

[PostgreSQL] PostgreSQL ๋‹ค์šด๋กœ๋“œ (WINDOW ์šด์˜์ฒด์ œ์— ์„ค์น˜)

DBMS(DataBase Management System) ์ค‘ ํ•˜๋‚˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๊ด€๋ฆฌ, ์šด์˜ํ•˜๋Š” ์†Œํ”„ํŠธ์›จ์–ด ์‚ฌ์šฉ์ž๋‚˜ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ --> DBMS๊ฐ€ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ์ดํ„ฐ์— ๋™์‹œ์— ์ ‘์†ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต์œ ํ•จ https://www.postgresql.org/download/windows/ PostgreSQL: Windows installers Windows installers Interactive installer by EDB Download the installer certified by EDB for all supported PostgreSQL versions. This installer includes the PostgreSQL server, pgAdmin; a graphical tool for managi..

[Linux] ๋‹ค์–‘ํ•œ ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด

๋ฆฌ๋ˆ…์Šค๋ฅผ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ๋„ ๊ณ„์† ๊ธฐ์–ต์ด ์•ˆ ๋‚  ๋•Œ ๋ณด๊ธฐ ์œ„ํ•œ ์ •๋ฆฌ~!~! ์•„๋Š” ๊ฑฐ ์ƒ๊ธธ ๋•Œ๋งˆ๋‹ค ์ถ”๊ฐ€ํ•˜๊ธฐ... vi ํŽธ์ง‘๊ธฐ ๋ช…๋ น์–ด gg # ํŒŒ์ผ ๋งจ ์•„๋ž˜ ๋ณด๊ธฐ G # ํŒŒ์ผ ๋งจ ์œ„ ๋ณด๊ธฐ :q! # ํŒŒ์ผ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ์žˆ์„ ๋•Œ ์ €์žฅ ์•ˆ ํ•˜๊ณ  ๋‚˜๊ฐ€๊ธฐ :q # ํŒŒ์ผ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ์—†์Œ, ๊ทธ๋ƒฅ ํŒŒ์ผ ๋‚˜๊ฐ€๊ธฐ :wq! # ํŒŒ์ผ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ์ €์žฅํ•˜๋ฉฐ ๋‚˜๊ฐ€๊ธฐ :์ˆซ์ž # ์ˆซ์ž ์œ„์น˜์— ํ•ด๋‹นํ•˜๋Š” ์—ด์œผ๋กœ ์ด๋™ /๊ฒ€์ƒ‰ # /์ดํ›„ ๋‹จ์–ด ์น˜๋ฉด ๊ฒ€์ƒ‰ ๊ฐ€๋Šฅ, /๋‹จ์–ด ๊ฒ€์ƒ‰ ํ›„ n ๋ˆ„๋ฅด๋ฉด ๋‹ค์Œ ๋‹จ์–ด๋กœ ์ด๋™ ls # ํ˜„์žฌ ๋ชฉ๋ก ๋ณด๊ธฐ ls [option] [directory/File] ls -l : ์ž์„ธํžˆ ์ถœ๋ ฅ mkdir # ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ ๋ช…๋ น์–ด chmod # ๊ถŒํ•œ ๊ด€๋ฆฌ chmod [options] mode[,mode] file1 [[file2 ...]..

Linux 2021.01.13

MobaXterm ์†Œ๊ฐœ(์œˆ๋„์šฐ WSL, ์›๊ฒฉ ์„œ๋ฒ„ GUI)

Putty๋‚˜ Ubuntu(์šฐ๋ถ„ํˆฌ) ๊ฐ™์€ ์„œ๋ฒ„ ์ ‘์† ํˆด์ธ๋ฐ ๋” ์˜ˆ์˜๋‹น (์ฝ”๋”ฉํ•  ๋• ์˜ˆ๋ป์•ผ ํ•  ๋ง› ๋‚˜์ฃ ?) mobaxterm.mobatek.net/download.html MobaXterm free Xserver and tabbed SSH client for Windows The ultimate toolbox for remote computing - includes X server, enhanced SSH client and much more! mobaxterm.mobatek.net ๋ฌด๋ฃŒ์ธ Home edition ๋‹ค์šด๋ฐ›๊ธฐ~ mobaxterm์€ ์—ฌ๋Ÿฌ ์ฐฝ์„ ํ•œ๊บผ๋ฒˆ์— ๋„์›Œ์„œ ์—ฌ๋Ÿฌ ์ฝ”๋“œ๋ฅผ ํ•œ๊บผ๋ฒˆ์— ์‹คํ–‰์‹œํ‚ฌ ์ˆ˜ ์žˆ๊ณ , ๋‹ค์–‘ํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ท€์—ฌ์šด๊ฑด ์˜ค๋ž˜๋™์•ˆ ์•„๋ฌด ์›€์ง์ž„ ์—†์œผ๋ฉด linux ํŽญ๊ท„ ๋‚˜์˜จ๋‹ค ใ…‹ใ…‹ใ…‹ใ…‹ ๊ท€..

Linux 2021.01.13

[CMD] Anaconda prompt์—์„œ ํ˜„์žฌ ๊ฒฝ๋กœ ๋ณด๊ธฐ

๋ฆฌ๋ˆ…์Šค ๊ธฐ๋ฐ˜ ํ„ฐ๋ฏธ๋„์—์„œ๋Š” pwd ๋ช…๋ น์–ด๋กœ ํ˜„์žฌ path ๋ณผ ์ˆ˜ ์žˆ๋‹ค. Anaconda prompt๋‚˜ ์œˆ๋„์šฐ cmd์—์„œ path ๋ณด๋Š” ๋ช…๋ น์–ด SET var = %cd% ECHO %var% ๋ณ€์ˆ˜์— cd ์ €์žฅ ํ›„ echo ๋ช…๋ น์–ด๋กœ ๋ณด๊ธฐ ๊ฐ„ -- ๋‹จ !

Note 2021.01.13
728x90