numpy.setdiff1d(array1, array2) : 2개의 array의 차집합
A_file.txt | B_file.txt |
Tomatoes are red
|
Tomatoes are red
|
import pandas as pd
import numpy as np
df_A = pd.read_csv('A_file.txt', names=['data_A'])
df_B = pd.read_csv('B_file.txt', names=['data_B'])
list_A = np.array(df_A['data_A'].tolist()) # df를 리스트로 변환
list_B = np.array(df_B['data_B'].tolist()) #
for x in np.setdiff1d(list_A,list_B): # np 차집합
print(x)
-----------------------------------------------------
Oranges are orange
Strawberries are red
'Python > Python For Analytics' 카테고리의 다른 글
[Python] replacement of Pandas dataframe NaN value (0) | 2020.02.16 |
---|---|
[Python] padnas dataframe URL Decode (2) | 2020.02.16 |
[Python] numpy.where 를 이용하여 컬럼을 다양한 데이터 타입과 비교 (0) | 2020.01.21 |
[Python] pandas dataframe 리스트로 변환 (0) | 2019.10.30 |
[Python] pandas rank를 이용한 순위 표시 (0) | 2019.10.28 |
[Python] pandas groupby - count, max, min, mean, sum, agg (0) | 2019.10.28 |
[Python] pandas의 sort_values를 이용한 dataframe 정렬 (0) | 2019.10.24 |
[Python] Pandas를 이용한 IIS 웹 로그 분석 (sc-bytes, cs-bytes) (0) | 2019.10.23 |