본문 바로가기

Tips/Solutions for problems

Delete redundant rows in pandas dataframe import modulesimport pandas as pd Create dataframe with duplicatesraw_data = {'first_name': ['Jason', 'Jason', 'Tina', 'Jake', 'Amy'], 'last_name': ['Miller', 'Miller', 'Ali', 'Milner', 'Cooze'], 'age': [42, 42, 36, 24, 73], 'preTestScore': [4, 4, 31, 2, 3], 'postTestScore': [25, 25, 57, 62, 70]} df = pd.DataFrame(raw_data, columns = ['first_name', 'last_name', 'age', 'preTestScore', 'postTestSc.. 더보기
how to insert dataframe data into mysql database using pymysql(pure python3 library) import pandas as pdimport mysql.connector from sqlalchemy import create_engine python을 이용해서 만든 데이터를 데이터베이스(DB)에 저장을 하기위한 모듈들이다. python3 에서는 Python에서 잘 작동하던 mysqldb 가 작동하지 않는다. 그래서 예전에 만들어둔 코드들이 더 이상 작동을 하지 않아 한 동안 애를 먹었던적이 있었다. 이번 기회에 이전 데이터를 python3를 이용해서 다시금 DB에 저장해두고 활용을 해 보고자 관련글을 작성해 둔다. 아래는 python3에서 pandas dataframe 으로 만들어진 데이터를 mysql or mariadb 에 삽입하는 코드이다. 이 단순한 몇을을 찾기 위해 얼마나 헤매였단가~ 먼산 .. 더보기
Mariadb Sovle : Plugin 'unix_socket' is not loaded The "unix_socket" has been called by mysql authentication process (maybe related to a partial migration of database to mariadb, now removed). To get all stuff back working go su:sudo su then follow:/etc/init.d/mysql stop mysqld_safe --skip-grant-tables & mysql -uroot This will completely stop mysql, bypass user authentication (no password needed) and connect to mysql with user "root".Now, in mys.. 더보기