matplotlib의 scatter 만들기 . 그래프 Scatter Plots in Python https://plot.ly/python/line-and-scatter/ reference : https://plot.ly/python/reference/#scatter plot 버전 체크 >>import plotly>>plotly.__version__ scatter 만들기 import plotly.plotly as pyimport plotly.graph_objs as go # Create random data with numpyimport numpy as np N = 1000random_x = np.random.randn(N)random_y = np.random.randn(N) # Create a trace..
파이썬에서 유니코드 스트림 다루기 # 입력 스트림과 출력 스트림을 연다input = open("input.txt", "rt", encoding="utf-16") output = open("output.txt", "wt", encoding="utf-8") # 유니코드 데이터 조각들을 스트리밍한다with input, output: while True: # 데이터 조각을 읽고 chunk = input.read(4096) if not chunk: break # 수직 탭을 삭제한다 chunk = chunk.replace("\u000B", "") # 데이터 조각을 쓴다 output.write(chunk)
응용: 쉘 스크립트를 이용해 해당 디렉토리의 파일들 모두 변경 - char-convert.sh#!/bin/bash LIST=`ls -A1 | grep ".csv"` for file in $LISTdo python ./char-convert.py $filedone - char-convert.py#!/usr/bin/python#-*- coding: utf-8 -*- import codecsimport sys file = sys.argv[1]file2 = file.split('.csv')[0]+"-2.csv" infile = codecs.open(file, 'r', encoding='utf-8')outfile = codecs.open(file2, 'w', encoding='euc_kr') for line in..
[Python] python matplotlib 에서 한글폰트 사용하기. font_manager 의 폰트 리스트 확인 아래 구문에서 에러 빵빵나오면 font_manager의 폰트 리스트 확인해서 잘 적용하는 거로! from matplotlib import font_manager, rc#font_fname = '/Library/Fonts/AppleGothic.ttf' # A font of your choice#font_fname = 'C:/Windows/Fonts/NanumGothic.ttf'#font_name = font_manager.FontProperties(fname=font_fname).get_name()font_name = 'Nanum Gothic Coding'rc('font', family=f..
[Python] .py 파일 실핼시 날짜(파라미터)입력 받아서 쓰기 아래 내용으로 test_param.py 라고 파일 생성 후 python 으로 컴파일. $python test_param.py 라고 실행하면 '날짜를 입력해주세요' 라고 나옴. $ python test_param.py 20170603 라고 입력하면 입력 받은 날짜로 실행됨 #! /usr/bin/python2.7# -*- coding: utf-8 -*- #import datetime#now = datetime.datetime.now()#dt = now.strftime('%Y-%m-%d_%H:%M:%S') import timefrom datetime import datetoday = date.today()yesterday = date.from..
어제 날짜 구하기 #! /usr/bin/python2.7# -*- coding: utf-8 -*- #import datetime#now = datetime.datetime.now()#dt = now.strftime('%Y-%m-%d_%H:%M:%S') import timefrom datetime import datetoday = date.today()yesterday = date.fromtimestamp(time.time() - 60*60*24)dty = yesterday.strftime('%Y-%m-%d'))dty = yesterday.strftime('%Y%m%d')dt = today.strftime('%Y-%m-%d')dt = today.strftime('%Y%m%d') print(" dty : "..