data analysis & visualization

anaconda 활용법

python2020. 6. 4. 21:44

아나콘다에서 할 수 있는 것을 먼저 확인해보자.

 

conda -h

conda --version : 아나콘다 버전확인

위와 같이 다양한 것을 할 수 있다.

 

자 이제 실제로 유용하게 쓸 수 잇는 목록을 크게 생성, 제거, 복구로 나누어 생각해보자.

 

생성 하기 전에 목록을 확인하는 방법은 다음과 같다.

conda env list : 가상환경 목록 확인 

 

생성

conda create -n [가상환경이름] python=[버전 ex) 3.6]

-> conda create -n test python=3.6

 

-y를 붙여 주면 질문을 무시하고 생성할 수 있다.

가상환경을 쓸지 말지 위와같이 설정할 수 있다. 

파이썬의 경우 패키지에 따라 함수가 없는 경우가 존재하므로 깔려 있는 패키지 목록과 버전을 확인해보자. 

 

환경을 공유하기 위해서 가상환경에 설치된 환경을 추출해보자. 

추출한 환경 목록으로 설치해보자.

 

삭제

 

백업

 

conda list --revisions

 

conda install --revision [revision num]

conda는 SQL의 savepoint와 다르게 새로 백업을 해도 savepoint보다 미래인 환경으로 돌아 갈 수 있다.

 

 

conda remove -n [가상환경] --all

 

주피터 노트북 커널 추가 

 

conda create -y -n [가상환경명] ipykernel

python -m ipykernel install --user --name [가상환경] --display-name "등록될 이름"

jupyter kernelspec list

 

 jupyter kernelspec remove [커널이름]

 

python -m ipykernel install --user --name pytorch --display-name "표출되고 싶은 커널 이름"

 

 

 

 

https://www.hancom.com/board/devdataView.do?board_seq=47&artcl_seq=4085&pageInfo.page=&search_text=

 

글로벌 소프트웨어의 리더, 한글과컴퓨터

◎ 첨부파일(보안모듈(Automation).zip)을 다운받으시고 압축을 해제 하시기 바랍니다.     구성물은 다음과 같습니다.    1. 보안모듈 소스    2. 보안모듈(FilePathCeckerModuleExample.dll)    3. 보안모듈 등록위치(레지스트리.JPG)    보안모듈을 특정위치에 설치하신 후, 레지스트리.JPG의 내용처럼, 보안모듈의 이름과 풀패스를 레지스트리 등록하신 뒤    사용하시기 바랍니다.    추가로 프로그램 소스에

www.hancom.com

C:\Program Files (x86)\Hnc//program files/Automation_Module 폴더 생성(폴더 명 무관)

압축 푼 파일 다운로드

 

경로 복사

(shift + F10 )>a

 

레지스트리 편집기 실행( regdit 입력)

 

HKEY_CURRENT_USER>Software>HNC>HwpAutomation>Modules

 

혹시 없는 경로가 있다면 키를 생성하여 정확한 이름 입력

 

Modules에 새로 만들기> 문자열값

이름은 기억하기 쉬운것으로(SecurityModule)로 저장

수정>값 데이터에 아까 복사한 경로를 붙여넣고 "을 제거하여 저장

 

https://www.youtube.com/watch?v=2Cv16_ZO5rk&list=PLalzN02jITUtke62DP2PHZ6mkDid72IC_&index=5

 


#shift alt h
#shift alt x
#shift alt l
#alt c

'python > hwp' 카테고리의 다른 글

win32com.client CLSIDToPackageMap 에러 해결  (0) 2020.06.09

from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.alert import Alert
import time
import os
import shutil
import re
import pandas as pd
directory=r'<저장될 경로>'
options = webdriver.ChromeOptions()
############
# 창이 뜨지 않게 설정
options.add_argument('headless')
# 창 크기 조절 설정
options.add_argument('window-size=1920x1080') 
options.add_argument("disable-gpu")
# F11 전체 화면 설정
options.add_argument('--start-fullscreen')
###############
# 기본 다운로드 경로 설정 /쓰지 말고 \\로 사용할 것.
options.add_experimental_option("prefs", {
  "download.default_directory": directory,
  "download.prompt_for_download": False,
  "download.directory_upgrade": True,
  "safebrowsing.enabled": True
})
#웹 열기
driver = webdriver.Chrome(executable_path='c:/selenium/chromedriver', chrome_options=options)

#될때까지 기다리게하기
wait= WebDriverWait(driver, 10)
temp2=wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "input#ststistic_period")))

#alert 팝업 확인하기
Alert(driver).text
#case 1
alert = driver.switch_to.alert
alert.accept()
#case 2
Alert(driver).accept()

#iframe 이동하기
# 상위로 이동
driver.switch_to.default_content()
driver.switch_to.frame(<iframe name>)

#iframe은 아닌데 비슷한게 있는듯.( 예 : chrome download)
shadow_root = driver.execute_script('return arguments[0].shadowRoot', <element>)

#select 버튼에 값 입력
Select(driver.find_element_by_css_selector(<CSS>)).select_by_value(<value>)

#캡처 
driver.get_screenshot_as_file('<파일명>.png')

#driver 내에 열린 창 목록 가져오기
main=driver.window_handles[0]
#사용중인 창 바꾸기
driver.switch_to.window(driver.window_handles[pop])

#자바스크립트 보내기
driver.execute_script('$javascript:doSelect();')

#요소로 마우스 이동시키기
action=ActionChains(driver)
action.move_to_element(mainmenu)        

 

그 외 참고

http://seiyria.com/bootstrap-slider/#example-1

'python > crawling' 카테고리의 다른 글

[Selenium] 기상자료 크롤링  (1) 2021.04.03
크롤링과 python  (0) 2021.04.03
나라장터 open api crawling  (0) 2020.03.01
[나라장터] 크롤링  (2) 2019.11.14
selenium 사용해서 위경도 가져오기  (0) 2019.03.20

temp

postgeSQL 사용을 위한 SQL에 넣는 방법과 가져오는 방법

연결하기

In [1]:
import psycopg2
In [3]:
!conda install -c anaconda psycopg2 -y
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/test/anaconda3/envs/jupyter

  added / updated specs:
    - psycopg2


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    krb5-1.16.4                |       h173b8e3_0         1.4 MB  anaconda
    libedit-3.1.20181209       |       hc058e9b_0         188 KB  anaconda
    libpq-11.5                 |       hd9ab2ff_2         2.5 MB  conda-forge
    psycopg2-2.8.4             |   py36h1ba5d50_0         171 KB  anaconda
    ------------------------------------------------------------
                                           Total:         4.2 MB

The following NEW packages will be INSTALLED:

  krb5               anaconda/linux-64::krb5-1.16.4-h173b8e3_0
  libedit            anaconda/linux-64::libedit-3.1.20181209-hc058e9b_0
  libpq              conda-forge/linux-64::libpq-11.5-hd9ab2ff_2
  psycopg2           anaconda/linux-64::psycopg2-2.8.4-py36h1ba5d50_0



Downloading and Extracting Packages
krb5-1.16.4          | 1.4 MB    | ##################################### | 100% 
libedit-3.1.20181209 | 188 KB    | ##################################### | 100% 
psycopg2-2.8.4       | 171 KB    | ##################################### | 100% 
libpq-11.5           | 2.5 MB    | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
In [2]:
conn = psycopg2.connect(
    "host='<도메인>' dbname='<DB명>' user='<사용자명>' password='<비번>'")
cur = conn.cursor()
In [3]:
from sqlalchemy import create_engine
e = create_engine('postgresql://<사용자명>:<비번>@<도메인>:<port>/<DB명>')

파일 DB에 밀어넣기

In [4]:
cur.execute("""SELECT table_name FROM information_schema.tables
       WHERE table_schema = 'public'""")
for table in cur.fetchall():
    print(table)
('test',)
('inventory',)
('AddressPoints',)
('test1',)
('test2',)
('fruits',)
('ptdj',)
('test3',)
('a',)
In [6]:
import pandas as pd
score = pd.DataFrame(
    {
        'date': ['2019-07-28'] * 4,
        'name': ['kim', 'lee', 'choi', 'park'],
        'age': [19, 20, 19, 20],
        'math_score': [91, 95, 92, 70],
        'pass_yn': [True, True, True, False]
    },
    columns=['date', 'name', 'age', 'math_score', 'pass_yn'])
In [7]:
score
Out[7]:
date name age math_score pass_yn
0 2019-07-28 kim 19 91 True
1 2019-07-28 lee 20 95 True
2 2019-07-28 choi 19 92 True
3 2019-07-28 park 20 70 False
In [8]:
score.to_sql(name='score', con=e)
In [9]:
cur.execute("""SELECT table_name FROM information_schema.tables
       WHERE table_schema = 'public'""")
for table in cur.fetchall():
    print(table)
('test',)
('inventory',)
('AddressPoints',)
('test1',)
('test2',)
('fruits',)
('ptdj',)
('test3',)
('a',)
('score',)

지도자료 밀어넣기

In [11]:
import pyproj
from fiona.crs import from_epsg

from sqlalchemy import *
from geoalchemy2 import Geometry
from geoalchemy2 import WKTElement
In [14]:
import geopandas as gpd
shp = gpd.read_file('./CTPRVN_201905/TL_SCCO_CTPRVN.shp', encoding='cp949')
shp
Out[14]:
CTPRVN_CD CTP_ENG_NM CTP_KOR_NM geometry
0 11 Seoul 서울특별시 POLYGON ((966987.226 1941110.946, 966987.119 1...
1 26 Busan 부산광역시 MULTIPOLYGON (((1138209.365 1673609.179, 11381...
2 27 Daegu 대구광역시 POLYGON ((1107777.593 1780522.269, 1107845.409...
3 28 Incheon 인천광역시 MULTIPOLYGON (((909743.413 1946023.117, 909736...
4 29 Gwangju 광주광역시 POLYGON ((932712.687 1696168.692, 932781.680 1...
5 30 Daejeon 대전광역시 POLYGON ((990946.725 1832389.260, 991057.692 1...
6 31 Ulsan 울산광역시 MULTIPOLYGON (((1167949.952 1710285.043, 11679...
7 36 Sejong-si 세종특별자치시 POLYGON ((971235.936 1844386.985, 971234.055 1...
8 41 Gyeonggi-do 경기도 MULTIPOLYGON (((931607.470 1894480.382, 931653...
9 42 Gangwon-do 강원도 MULTIPOLYGON (((1163759.191 1909653.101, 11637...
10 43 Chungcheongbuk-do 충청북도 POLYGON ((1042689.435 1917662.690, 1042731.339...
11 44 Chungcheongnam-do 충청남도 MULTIPOLYGON (((919207.926 1777520.288, 919117...
12 45 Jeollabuk-do 전라북도 MULTIPOLYGON (((902676.539 1717491.597, 902679...
13 46 Jellanam-do 전라남도 MULTIPOLYGON (((934759.097 1614071.335, 934759...
14 47 Gyeongsangbuk-do 경상북도 MULTIPOLYGON (((1171290.353 1782200.848, 11712...
15 48 Gyeongsangnam-do 경상남도 MULTIPOLYGON (((1053643.218 1612344.022, 10536...
16 50 Jeju-do 제주특별자치도 MULTIPOLYGON (((885004.560 1458756.461, 884996...
In [15]:
shp.plot(column='CTP_KOR_NM')
Out[15]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f5ce96ab390>
In [20]:
shp1 = shp.copy()
In [21]:
shp1.to_sql('a', e, if_exists='replace', index=False)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
pandas/_libs/lib.pyx in pandas._libs.lib.infer_dtype()

TypeError: Cannot convert GeometryArray to numpy.ndarray

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-21-b2691c00fb27> in <module>
----> 1 shp1.to_sql('a', e, if_exists='replace', index=False)

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/core/generic.py in to_sql(self, name, con, schema, if_exists, index, index_label, chunksize, dtype, method)
   2661             chunksize=chunksize,
   2662             dtype=dtype,
-> 2663             method=method,
   2664         )
   2665 

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/io/sql.py in to_sql(frame, name, con, schema, if_exists, index, index_label, chunksize, dtype, method)
    519         chunksize=chunksize,
    520         dtype=dtype,
--> 521         method=method,
    522     )
    523 

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/io/sql.py in to_sql(self, frame, name, if_exists, index, index_label, schema, chunksize, dtype, method)
   1312             index_label=index_label,
   1313             schema=schema,
-> 1314             dtype=dtype,
   1315         )
   1316         table.create()

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/io/sql.py in __init__(self, name, pandas_sql_engine, frame, index, if_exists, prefix, index_label, schema, keys, dtype)
    620         if frame is not None:
    621             # We want to initialize based on a dataframe
--> 622             self.table = self._create_table_setup()
    623         else:
    624             # no data provided, read-only mode

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/io/sql.py in _create_table_setup(self)
    866         from sqlalchemy import Table, Column, PrimaryKeyConstraint
    867 
--> 868         column_names_and_types = self._get_column_names_and_types(self._sqlalchemy_type)
    869 
    870         columns = [

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/io/sql.py in _get_column_names_and_types(self, dtype_mapper)
    858         column_names_and_types += [
    859             (str(self.frame.columns[i]), dtype_mapper(self.frame.iloc[:, i]), False)
--> 860             for i in range(len(self.frame.columns))
    861         ]
    862 

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/io/sql.py in <listcomp>(.0)
    858         column_names_and_types += [
    859             (str(self.frame.columns[i]), dtype_mapper(self.frame.iloc[:, i]), False)
--> 860             for i in range(len(self.frame.columns))
    861         ]
    862 

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/io/sql.py in _sqlalchemy_type(self, col)
    950         # Infer type of column, while ignoring missing values.
    951         # Needed for inserting typed data containing NULLs, GH 8778.
--> 952         col_type = lib.infer_dtype(col, skipna=True)
    953 
    954         from sqlalchemy.types import (

pandas/_libs/lib.pyx in pandas._libs.lib.infer_dtype()

pandas/_libs/lib.pyx in pandas._libs.lib._try_infer_map()

AttributeError: 'GeometryDtype' object has no attribute 'base'

바로 넣으면 에러가 뜸 shapely를 활용할 예정

In [27]:
import shapely
In [25]:
test = shp1.geometry[1]
test
Out[25]:
In [49]:
shapely.wkt.dumps(test)[1:100]
Out[49]:
'ULTIPOLYGON (((1138209.3649876813869923 1673609.1794120199047029, 1138184.5415377025492489 1673597.'
In [29]:
shapely.wkt.loads(shapely.wkt.dumps(shp1.geometry[1]))
Out[29]:
In [30]:
shp1['geometry'] = shp1.apply(lambda x: shapely.wkt.dumps(x.geometry), axis=1)
In [31]:
shp1
Out[31]:
CTPRVN_CD CTP_ENG_NM CTP_KOR_NM geometry
0 11 Seoul 서울특별시 POLYGON ((966987.2258638255298138 1941110.9461...
1 26 Busan 부산광역시 MULTIPOLYGON (((1138209.3649876813869923 16736...
2 27 Daegu 대구광역시 POLYGON ((1107777.5933314983267337 1780522.268...
3 28 Incheon 인천광역시 MULTIPOLYGON (((909743.4125806831289083 194602...
4 29 Gwangju 광주광역시 POLYGON ((932712.6874476601369679 1696168.6917...
5 30 Daejeon 대전광역시 POLYGON ((990946.7248482395661995 1832389.2596...
6 31 Ulsan 울산광역시 MULTIPOLYGON (((1167949.9516389914788306 17102...
7 36 Sejong-si 세종특별자치시 POLYGON ((971235.9357597539201379 1844386.9848...
8 41 Gyeonggi-do 경기도 MULTIPOLYGON (((931607.4699318613857031 189448...
9 42 Gangwon-do 강원도 MULTIPOLYGON (((1163759.1907545514404774 19096...
10 43 Chungcheongbuk-do 충청북도 POLYGON ((1042689.4352804463123903 1917662.690...
11 44 Chungcheongnam-do 충청남도 MULTIPOLYGON (((919207.9262066939845681 177752...
12 45 Jeollabuk-do 전라북도 MULTIPOLYGON (((902676.5389720955863595 171749...
13 46 Jellanam-do 전라남도 MULTIPOLYGON (((934759.0967011926695704 161407...
14 47 Gyeongsangbuk-do 경상북도 MULTIPOLYGON (((1171290.3528821258805692 17822...
15 48 Gyeongsangnam-do 경상남도 MULTIPOLYGON (((1053643.2178877647966146 16123...
16 50 Jeju-do 제주특별자치도 MULTIPOLYGON (((885004.5599632168887183 145875...
In [32]:
type(shp1)
Out[32]:
geopandas.geodataframe.GeoDataFrame
In [33]:
shp1.to_sql('a', e, if_exists='replace', index=False)

밀어넣기가 잘 된거 같으나 ...

In [34]:
import pandas as pd
shp1 = pd.read_sql('select * from a', e)
shp1
Out[34]:
CTPRVN_CD CTP_ENG_NM CTP_KOR_NM geometry
0 11 Seoul 서울특별시 POLYGON ((966987.2258638255298138 1941110.9461...
1 26 Busan 부산광역시 MULTIPOLYGON (((1138209.3649876813869923 16736...
2 27 Daegu 대구광역시 POLYGON ((1107777.5933314983267337 1780522.268...
3 28 Incheon 인천광역시 MULTIPOLYGON (((909743.4125806831289083 194602...
4 29 Gwangju 광주광역시 POLYGON ((932712.6874476601369679 1696168.6917...
5 30 Daejeon 대전광역시 POLYGON ((990946.7248482395661995 1832389.2596...
6 31 Ulsan 울산광역시 MULTIPOLYGON (((1167949.9516389914788306 17102...
7 36 Sejong-si 세종특별자치시 POLYGON ((971235.9357597539201379 1844386.9848...
8 41 Gyeonggi-do 경기도 MULTIPOLYGON (((931607.4699318613857031 189448...
9 42 Gangwon-do 강원도 MULTIPOLYGON (((1163759.1907545514404774 19096...
10 43 Chungcheongbuk-do 충청북도 POLYGON ((1042689.4352804463123903 1917662.690...
11 44 Chungcheongnam-do 충청남도 MULTIPOLYGON (((919207.9262066939845681 177752...
12 45 Jeollabuk-do 전라북도 MULTIPOLYGON (((902676.5389720955863595 171749...
13 46 Jellanam-do 전라남도 MULTIPOLYGON (((934759.0967011926695704 161407...
14 47 Gyeongsangbuk-do 경상북도 MULTIPOLYGON (((1171290.3528821258805692 17822...
15 48 Gyeongsangnam-do 경상남도 MULTIPOLYGON (((1053643.2178877647966146 16123...
16 50 Jeju-do 제주특별자치도 MULTIPOLYGON (((885004.5599632168887183 145875...
In [35]:
type(shp1)
Out[35]:
pandas.core.frame.DataFrame

가지고 오면 자료의 타입은 pandas 므로 geopandas 로 바꾸어 줘야되며

In [36]:
import geopandas as gpd
shp1 = gpd.GeoDataFrame(shp1)
type(shp1)
Out[36]:
geopandas.geodataframe.GeoDataFrame
In [37]:
shp1.plot()
/home/test/anaconda3/envs/jupyter/lib/python3.6/site-packages/geopandas/plotting.py:351: FutureWarning:     You are passing non-geometry data to the GeoSeries constructor. Currently,
    it falls back to returning a pandas Series. But in the future, we will start
    to raise a TypeError instead.
  expl_series = geopandas.GeoSeries(geoms)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-37-1665a42b35a0> in <module>
----> 1 shp1.plot()

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/geopandas/geodataframe.py in plot(self, *args, **kwargs)
    654         from there.
    655         """
--> 656         return plot_dataframe(self, *args, **kwargs)
    657 
    658     plot.__doc__ = plot_dataframe.__doc__

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/geopandas/plotting.py in plot_dataframe(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, classification_kwds, missing_kwds, **style_kwds)
    545             figsize=figsize,
    546             markersize=markersize,
--> 547             **style_kwds
    548         )
    549 

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/geopandas/plotting.py in plot_series(s, cmap, color, ax, figsize, **style_kwds)
    351     expl_series = geopandas.GeoSeries(geoms)
    352 
--> 353     geom_types = expl_series.type
    354     poly_idx = np.asarray((geom_types == "Polygon") | (geom_types == "MultiPolygon"))
    355     line_idx = np.asarray(

~/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5272             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5273                 return self[name]
-> 5274             return object.__getattribute__(self, name)
   5275 
   5276     def __setattr__(self, name: str, value) -> None:

AttributeError: 'Series' object has no attribute 'type'

dump로 바꾼부분때문에 그림이 그려지지 않으므로 loads해주고 사용하여야 된다.

In [38]:
shp1['geometry'] = shp1.apply(lambda x: shapely.wkt.loads(x.geometry), axis=1)
In [39]:
shp1.plot()
Out[39]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f5ce936fe10>
In [40]:
shp.plot(column='CTP_KOR_NM')
Out[40]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f5ce933e828>

동적인 그림 그리기

In [41]:
from fiona.crs import from_epsg
In [42]:
import folium
m = folium.Map(location=[40.730610, -73.935242],
               tiles='Stamen Toner',
               zoom_start=12,
               control_scale=True,
               prefer_canvas=True)
In [43]:
m
Out[43]:
In [ ]:
 

'python' 카테고리의 다른 글

pandas-profiling  (0) 2020.06.11
anaconda 활용법  (0) 2020.06.04
python 메일 보내기  (0) 2020.02.24
jupyter notebook 가상환경에 basemap 설치하기  (0) 2020.02.23
numpy 정리(1)  (0) 2020.02.18

Untitled4
In [1]:
import pandas as pd
from bs4 import BeautifulSoup
import requests
import urllib
from urllib import parse
from datetime import datetime, timedelta
from datetime import date
import re 
import math
In [2]:
today = date.today()
start=re.sub('-','',str(today - timedelta(days=60)))
end=re.sub('-','',str(today))

priceUp=2000000
priceDown=200000000000
key='오픈api'
In [4]:
link='http://apis.data.go.kr/1230000/BidPublicInfoService/getBidPblancListInfoServcPPSSrch?type=json&inqryDiv=1&dminsttNm='+parse.quote('해양수산부')+'&inqryBgnDt='+start+'&inqryEndDt='+end+'&pageNo=1&numOfRows=1&ServiceKey='+key
url = parse.urlparse(link) 
query = parse.parse_qs(url.query)
base='http://apis.data.go.kr/1230000/BidPublicInfoService/getBidPblancListInfoServcPPSSrch?'
link=base+parse.urlencode(query, doseq=True)
In [5]:
request=urllib.request.urlopen(link).read().decode('utf-8')
n=math.ceil(json.loads(request)['response']['body']['totalCount']*.1)
n
Out[5]:
70
In [6]:
page=1
link='http://apis.data.go.kr/1230000/BidPublicInfoService/getBidPblancListInfoServcPPSSrch?type=json&inqryDiv=1&dminsttNm='+parse.quote('해양수산부')+'&inqryBgnDt='+start+'&inqryEndDt='+end+'&pageNo='+str(page)+'&numOfRows=10&ServiceKey='+key
url = parse.urlparse(link) 
query = parse.parse_qs(url.query)
link=base+parse.urlencode(query, doseq=True)
request=urllib.request.urlopen(link).read().decode('utf-8')
df=pd.DataFrame(json.loads(request)['response']['body']['items'])
df2=df[['bidNtceNm','asignBdgtAmt','bidBeginDt','bidClseDt','opengDt','bidMethdNm','cntrctCnclsMthdNm','dminsttNm','dminsttCd','bidNtceNo','reNtceYn','ntceKindNm','bidNtceDtlUrl']]
df2.rename(columns = {'asignBdgtAmt' : '배정예산','bidNtceNm':'공고명','bidBeginDt':'입찰개시일','bidClseDt':'입찰마감일'
                  ,'opengDt':'개찰일시','bidMethdNm':'입찰방식','cntrctCnclsMthdNm':'계약체결방법','dminsttCd':'수요기관코드'
                 ,'dminsttNm':'수요기관명','bidNtceNo':'입찰공고번호','reNtceYn':'재공고여부','ntceKindNm':'공고종류','bidNtceDtlUrl':'링크'}, inplace = True)
data=df2
/root/anaconda3/envs/jupyter/lib/python3.6/site-packages/pandas/core/frame.py:4133: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  errors=errors,
In [7]:
data
Out[7]:
공고명 배정예산 입찰개시일 입찰마감일 개찰일시 입찰방식 계약체결방법 수요기관명 수요기관코드 입찰공고번호 재공고여부 공고종류 링크
0 2020~2021년 사무기기 유지보수 용역(재공고) 192000000 2020-01-07 10:00:00 2020-01-13 14:00:00 2020-01-13 15:00:00 전자입찰 제한(총액)협상에의한계약 해양수산부 1192000 20191239804 N 변경 http://www.g2b.go.kr:8081/ep/invitation/publis...
1 2020년 해양안전종합정보시스템(GICOMS) 유지보수 및 운영 435593200 2020-01-08 10:00:00 2020-01-14 10:00:00 2020-01-14 11:00:00 전자입찰 제한(총액)협상에의한계약 해양수산부 1192000 20200100306 Y 일반 http://www.g2b.go.kr:8081/ep/invitation/publis...
2 2020년 실시간 해양환경 어장정보시스템 유지보수 351647806 2020-01-07 10:00:00 2020-01-07 12:00:00 2020-01-07 13:00:00 전자시담 수의(총액) 해양수산부 국립수산과학원 1192266 20200100313 N 일반 http://www.g2b.go.kr:8081/ep/invitation/publis...
3 2020년도 로란-C 시설장비 유지보수 용역(긴급) 40000000 2020-01-08 10:00:00 2020-01-14 10:00:00 2020-01-14 11:00:00 전자입찰 제한(총액)협상에의한계약 해양수산부 국립해양측위정보원 1192464 20191243271 N 긴급 http://www.g2b.go.kr:8081/ep/invitation/publis...
4 2020년도 항로표지 전산관리시스템 유지관리 용역 121344200 2020-01-10 10:00:00 2020-01-14 10:00:00 2020-01-14 11:00:00 전자입찰 제한(총액)협상에의한계약 해양수산부 여수지방해양수산청 1192359 20200101328 Y 일반 http://www.g2b.go.kr:8081/ep/invitation/publis...
5 평택·당진항 중앙집중형 종합보안시스템 유지보수 용역 191929400 2020-01-10 10:00:00 2020-01-14 10:00:00 2020-01-14 11:00:00 전자입찰 제한(총액)협상에의한계약 해양수산부 평택지방해양수산청 1192365 20200101339 Y 일반 http://www.g2b.go.kr:8081/ep/invitation/publis...
6 2020년도 항만보안 종합감시시스템 유지보수 용역 141511400 2020-01-10 12:00:00 2020-01-14 12:00:00 2020-01-14 13:00:00 전자입찰 제한(총액)협상에의한계약 해양수산부 부산지방해양수산청 제주해양수산관리단 1192373 20200101590 Y 일반 http://www.g2b.go.kr:8081/ep/invitation/publis...
7 2020년도 항로표지 관리시스템 유지보수 용역 98250000 2020-01-03 20:00:00 2020-01-13 10:00:00 2020-01-13 11:00:00 전자입찰 제한(총액) 해양수산부 부산지방해양수산청 1192357 20200102162 N 일반 http://www.g2b.go.kr:8081/ep/invitation/publis...
8 포항 영일만항 해경부두 축조공사 기본 및 실시설계용역 1710000000 2020-01-20 16:00:00 직찰 제한경쟁 해양수산부 포항지방해양수산청 1192364 20200102532 N 일반 http://www.g2b.go.kr:8081/ep/invitation/publis...
9 울릉군 남양1리 연안정비사업 실시설계용역 780000000 2020-01-20 16:00:00 직찰 제한경쟁 해양수산부 포항지방해양수산청 1192364 20200102573 N 일반 http://www.g2b.go.kr:8081/ep/invitation/publis...
In [ ]:
 

'python > crawling' 카테고리의 다른 글

[Selenium] 기상자료 크롤링  (1) 2021.04.03
크롤링과 python  (0) 2021.04.03
python selenium 자주쓴거 정리  (0) 2020.03.23
[나라장터] 크롤링  (2) 2019.11.14
selenium 사용해서 위경도 가져오기  (0) 2019.03.20

python 메일 보내기

python2020. 2. 24. 00:09

gmail 접속> 우측 상단에 톱니바퀴모양 환경설정 클릭(아래 그림 참고) > 전달 및 POP/IMAP 클릭> IMAP사용

위를 아래와 같이 변경

 

gmail은 보안이 철저하므로 아래와 같이 설정이 필요함.

 

네이버는 아래 그림과 같이 환경설정 클릭 

위와같이 설정

 

 

 

참고 : http://blog.naver.com/PostView.nhn?blogId=shino1025&logNo=221298198979&categoryNo=14&parentCategoryNo=0&viewDate=¤tPage=1&postListTopCurrentPage=1&from=postView&userTopListOpen=true&userTopListCount=10&userTopListManageOpen=false&userTopListCurrentPage=1

 

[Python] 파이썬으로 이메일 보내기

이번 포스팅에서는 파이썬에서 이메일을 사용하는 방법에 대해 알아보자. 사실 이메일을 보내기 위해서는 ...

blog.naver.com

http://hleecaster.com/python-email-automation/

 

파이썬 이메일 자동화 (이메일 대량 발송) - 아무튼 워라밸

회사에서 업무를 하다 보면 여러명에게 각각 다른 제목과 내용으로 (심지어 각각 다른 첨부파일을 포함해서) 이메일을 보내야 할 때가 있다. 손으로 보내긴 귀찮으니 파이썬으로 자동화하는 코드를 최대한 간단히 짜보았다.

hleecaster.com