pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org kafka-python

 

참고: https://curryyou.tistory.com/179

 

[파이썬] pip 설치 SSLError 오류 해결 방법: SSLCertVerificationError [SSL: CERTIFICATE_VERIFY_FAILED]

회사 컴퓨터나 사내망 등의 환경에서 pip로 파이썬 라이브러리를 설치하면, 아래와 같이 SSL관련 에러가 뜰 때가 있다. (방화벽/프록시 등의 이슈로, 해결 방법은 간단하다) pip install requests <터미

curryyou.tistory.com

 

pip.conf 파일을 만들면 매번 옵션을 추가할 필요가 없다.

https://pip.pypa.io/en/stable/topics/configuration/

Posted by poterius
,
iris_df = pd.DataFrame(iris.data, columns = iris.feature_names)
iris_df.columns = ["sepal_length", "sepal_width", "petal_length", "petal_width"]
iris_df.head(5)

df = iris_df[["sepal_length", "sepal_width"]]
display(df.head(5))
df = round(df)
df2 = df.groupby(["sepal_length", "sepal_width"]).size()
df3= df2.unstack()
display(df3)

# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(5, 5))

# Generate a custom diverging colormap
cmap = sns.diverging_palette(100, 10, as_cmap=True)

# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(df3, cmap=cmap, center=0,
            square=True, linewidths=.5, cbar_kws={"shrink": .5})

Posted by poterius
,

dataframe이 notebook cell의 마지막에 있으면 내용을 예쁘게 table로 보여주는데, 

loop안에 있을 경우 table이 보이지 않는다. 

print(df)하면 내용은 보이기는 하나 예쁜 table이 아니고.. 

이경우 IPython.display를 사용한다.

 

from sklearn.datasets import load_iris
import pandas as pd
from IPython.display import display, HTML

iris = datasets.load_iris()

data = pd.DataFrame(data= np.c_[iris['data'], iris['target']],
                     columns= iris['feature_names'] + ['target'])
target = data['target'].unique()
target
for t in target:
    display(data[data['target'] == t].head(2))

Posted by poterius
,