반응형
반응형

Pandas .Series 의 item , to_CSV

pandas.Series.items

 

 

s = pd.Series(['A', 'B', 'C'])
>>> for index, value in s.items():
...     print(f"Index : {index}, Value : {value}")
Index : 0, Value : A
Index : 1, Value : B
Index : 2, Value : C

https://github.com/pandas-dev/pandas/blob/v1.4.1/pandas/core/series.py#L1662-L1689

 

GitHub - pandas-dev/pandas: Flexible and powerful data analysis / manipulation library for Python, providing labeled data struct

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more - GitHub - pandas-dev/...

github.com

 

 

 

 

반응형
반응형

wordcloud 패키지 설치 명령어

conda install -c conda-forge wordcloud




만약 설치후에도  오류가 발생한다면

wordcloud 패키지를 지우고 선행 패키지인 pillow 패키지를 먼저 설치한 후 wordcloud 패키지를 다시 설치한다.

 

> stylecloud 도 설치 하자. 

pip install stylecloud

 

 

 

반응형
반응형

최근에 다시 쓸 일이 있어서 VSCode에서 python을 자동컴파일 할 수 있도록 셋팅했다. 

 

결국 한글을 얼마나 잘 가공할 수 있느냐가 문제인데. 

 

아나콘다를 이용해서 윈도우에서 VScode에서 개발 할 수 있게 셋팅하기. 

 

VScode 확장에서 파이썬, extension pack 설치하고. 

 

결국 여러 검색 내용을 참조하지만. 

 

* 파이썬 가상환경을 만들어야 한다.

* conda로 할꺼면 가상환경내에서 conda로 설치해서 반영될 수 있도록 한다. 

* vscode에서 해당 파이썬 파일을 실행할때, 컴파일이 제대로 안되면  작업하는 파일의 경로를 꼭 확인해봐라. 

* 파일 경로, 인스톨된 라이브러리 만 잘 확인하면 왠만해서는 구문오류만 생긴다. 

 

#작업하는 경로(위치)가 어디인지 확인
#print(os.getcwd())
#현재 파일 이름
#print(__file__)
#현재 파일 실제 경로
#print(os.path.realpath(__file__))

 

https://konlpy.org/ko/latest/

 

KoNLPy: 파이썬 한국어 NLP — KoNLPy 0.6.0 documentation

KoNLPy: 파이썬 한국어 NLP KoNLPy(“코엔엘파이”라고 읽습니다)는 한국어 정보처리를 위한 파이썬 패키지입니다. 설치법은 이 곳을 참고해주세요. NLP를 처음 시작하시는 분들은 시작하기 에서 가

konlpy.org

 

반응형
반응형

os.getcwd()

import os

#작업하는 경로(위치)가 어디인지 확인
print(os.getcwd())

#절대경로
with open("D:/python/res/path_test/test.txt", "r", encoding="utf-8") as f:
    data = f.read()
    print(data)

#상대경로
with open("path_test/test.txt", "r", encoding="utf-8") as f:
    data = f.read()
    print(data)

cwd = current working directory  현재 작업 중인 디렉터리(폴더)를 의미하고, 

get = 얻어온다는 의미가 있으니, 현재 작업 중인 폴더를 얻어온다는 의미가 되겠습니다.

반응형
반응형

 

pip install pandas 

 

conda install -c anaconda pandas 

When working with tabular data, such as data stored in spreadsheets or databases, pandas is the right tool for you. pandas will help you to explore, clean, and process your data. In pandas, a data table is called a DataFrame.

반응형
반응형

  현재 년, 월, 일, 시, 분, 초 문자열로 표현하기 (yyyymmddhh24miss 형태) 

## 시간 표시  ##################################### 
import time
import datetime
now = datetime.datetime.now()
nowStr = "{:%Y%m%d%H%M%S}".format(now)
timeserise = time.time()
timeserise = str(int(timeserise))
#print(timeserise)
print(now)
print(" 년월일시분초 :" + nowStr)

#################################################
반응형

+ Recent posts