목록Programming (97)
59doit
import numpy as np import pandas as pd PREVIOUS_MAX_ROWS = pd.options.display.max_rows pd.options.display.max_rows = 20 np.random.seed(12345) import matplotlib.pyplot as plt plt.rc('figure', figsize=(10, 6)) np.set_printoptions(precision=4, suppress=True) 데이터 집계 df # # key1 key2 data1 data2 # 0 a one 0.981007 -1.006219 # 1 a two -0.873717 -0.902148 # 2 b one -1.015634 0.752769 # 3 b two -0.41124..
import numpy as np import pandas as pd PREVIOUS_MAX_ROWS = pd.options.display.max_rows pd.options.display.max_rows = 20 np.random.seed(12345) import matplotlib.pyplot as plt plt.rc('figure', figsize=(10, 6)) np.set_printoptions(precision=4, suppress=True) group by df = pd.DataFrame({'key1' : ['a', 'a', 'b', 'b', 'a'], 'key2' : ['one', 'two', 'one', 'two', 'one'], 'data1' : np.random.randn(5), 'd..
import numpy as np import pandas as pd pd.options.display.max_rows = 20 np.random.seed(12345) import matplotlib.pyplot as plt plt.rc('figure', figsize=(10, 6)) np.set_printoptions(precision=4, suppress=True) 시계열 데이터는 일반적으로 시간 순서대로 나열 data = pd.read_csv('C:/macrodata.csv') data.head() periods = pd.PeriodIndex(year=data.year, quarter=data.quarter, name='date') columns = pd.Index(['realgdp', 'infl'..
combining ▷ 벡터화된 if-else 구문을 표현하는 NumPy 의 where()함수 a = pd.Series([np.nan, 2.5, np.nan, 3.5, 4.5, np.nan], index=['f', 'e', 'd', 'c', 'b', 'a']) b = pd.Series(np.arange(len(a), dtype=np.float64), index=['f', 'e', 'd', 'c', 'b', 'a']) b[-1] = np.nan a # # f NaN # e 2.5 # d NaN # c 3.5 # b 4.5 # a NaN # dtype: float64 b # # f 0.0 # e 1.0 # d 2.0 # c 3.0 # b 4.0 # a NaN # dtype: float64 ▷ null 이면 b..