Pandas: BUG: concat이 λ‹€λ₯΄λ©΄ DataFrame μ—΄ 이름을 μ›ν•˜μ§€ μ•Šκ²Œ μ •λ ¬ν•©λ‹ˆλ‹€.

에 λ§Œλ“  2013λ…„ 08μ›” 17일  Β·  36μ½”λ©˜νŠΈ  Β·  좜처: pandas-dev/pandas

DataFramesλ₯Ό μ—°κ²°ν•  λ•Œ μ—΄ 이름 간에 차이점이 있으면 μ—΄ 이름이 영숫자 순으둜 μ •λ ¬
이 μ’…λ₯˜λŠ” λ¬Έμ„œν™”λ˜μ§€ μ•Šμ•˜μœΌλ©° μ›ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. ν™•μ‹€νžˆ κΈ°λ³Έ λ™μž‘μ€ μ •λ ¬λ˜μ§€ μ•Šμ•„μ•Ό ν•©λ‹ˆλ‹€. νŽΈμ§‘: SQLμ—μ„œμ™€ 같은 ν‘œμ€€ μˆœμ„œλŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€. df1의 μ—΄(df1κ³Ό λ™μΌν•œ μˆœμ„œ), df2의 μ—΄(κ³ μœ ν•˜κ²Œ)(곡톡 열이 적음)(df2와 λ™μΌν•œ μˆœμ„œ). μ˜ˆμ‹œ:

df4a = DataFrame(columns=['C','B','D','A'], data=np.random.randn(3,4))
df4b = DataFrame(columns=['C','B','D','A'], data=np.random.randn(3,4))
df5  = DataFrame(columns=['C','B','E','D','A'], data=np.random.randn(3,5))

print "Cols unsorted:", concat([df4a,df4b])
# Cols unsorted:           C         B         D         A

print "Cols sorted", concat([df4a,df5])
# Cols sorted           A         B         C         D         E
``'
API Design Reshaping

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

이 λ™μž‘μ€ μ‹€μ œλ‘œ 맀우 μ˜ˆμƒμΉ˜ λͺ»ν•œ 것이며 저도 μš°μ—°νžˆ λ°œκ²¬ν–ˆμŠ΅λ‹ˆλ‹€.

 >>> df = pd.DataFrame()

>>> df['b'] = [1,2,3]
>>> df['c'] = [1,2,3]
>>> df['a'] = [1,2,3]
>>> print(df)
   b  c  a
0  1  1  1
1  2  2  2
2  3  3  3

[3 rows x 3 columns]
>>> df2 = pd.DataFrame({'a':[4,5]})
>>> df3 = pd.concat([df, df2])

μˆœμ§„ν•˜κ²Œλ„ μ—΄μ˜ μˆœμ„œκ°€ μœ μ§€λ  κ²ƒμœΌλ‘œ μ˜ˆμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€. λŒ€μ‹  열이 μ •λ ¬λ©λ‹ˆλ‹€.

>>> print(df3)
   a   b   c
0  1   1   1
1  2   2   2
2  3   3   3
0  4 NaN NaN
1  5 NaN NaN

[5 rows x 3 columns]

이것은 λ‹€μŒκ³Ό 같이 μ›λž˜ 열을 λ‹€μ‹œ μƒ‰μΈν™”ν•˜μ—¬ μˆ˜μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

>>> df4 = df3.reindex_axis(df.columns, axis=1)
>>> print(df4)
    b   c  a
0   1   1  1
1   2   2  2
2   3   3  3
0 NaN NaN  4
1 NaN NaN  5

[5 rows x 3 columns]

μ—¬μ „νžˆ 이 μžλ™ 정렬이 μˆ˜ν–‰λ˜κ³  λ‚΄κ°€ μ•„λŠ” ν•œ λΉ„ν™œμ„±ν™”ν•  수 μ—†λ‹€λŠ” 것이 직관적이지 μ•Šμ€ 것 κ°™μŠ΅λ‹ˆλ‹€.

λͺ¨λ“  36 λŒ“κΈ€

이것을 κ°„λ‹¨νžˆ _생각_ ν•˜λ©΄ λ…μŠ€νŠΈλ§μ΄ λ‹€μŒκ³Ό 같이 λͺ…μ‹œλ˜μ–΄ μžˆλŠ” Index.intersectionμ—μ„œ μœ λž˜ν•©λ‹ˆλ‹€.

두 인덱슀 개체의 ꡐ차λ₯Ό ν˜•μ„±ν•©λ‹ˆλ‹€. 결과의 정렬이 보μž₯λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

μ–΄λ–€ κ²½μš°μ— ν‘œμ‹œ/μ •λ ¬λ˜λŠ”μ§€ ν™•μ‹€ν•˜μ§€ μ•Šμ§€λ§Œ 열이 λ™μΌν•œ 경우(첫 번째 μ—΄μ—μ„œ)λŠ” λ™μΌν•œ κ²°κ³Όλ₯Ό λ°˜ν™˜ν•˜λŠ” νŠΉμˆ˜ν•œ κ²½μš°μž…λ‹ˆλ‹€...

@smcierney λŒ€μ‹  μ–΄λ–€ μˆœμ„œλ₯Ό κΈ°λŒ€ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?

λ‚˜λŠ” λ£¨ν”„μ˜ 빈 ν”„λ ˆμž„μ— ν”„λ ˆμž„μ„ μ—°κ²°ν•˜λ €κ³  μ‹œλ„ν–ˆκΈ° λ•Œλ¬Έμ—(예: λͺ©λ‘μ— μš”μ†Œ μΆ”κ°€) μžλ™ 정렬이 μ•½κ°„ μ„±κ°€μ‹œλ‹€λŠ” 것을 μ•Œμ•˜μŠ΅λ‹ˆλ‹€. 그런 λ‹€μŒ μ—΄ μˆœμ„œκ°€ λ³€κ²½λ˜μ—ˆμŒμ„ κΉ¨λ‹¬μ•˜μŠ΅λ‹ˆλ‹€. μΆ•=1을 따라 μ—°κ²°ν•˜λŠ” 경우 이 λ³€κ²½ 사항은 μΈλ±μŠ€μ—λ„ μ μš©λ©λ‹ˆλ‹€.

@smcinerney 의 κ²½μš°μ™€ μœ μ‚¬ν•œ 경우

λ”°λΌμ„œ λ‚˜λŠ” "hack"을 μΌμŠ΅λ‹ˆλ‹€ (μ’€ 바보 κ°™μ§€λ§Œ)

sorted = pd.concat(frameList, axis=axis, join=join, join_axes=join_axes, ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False)

if join_axes:
    return sorted
elif sort:
    return sorted
else:
    # expand all original orders in each frame
    sourceOrder = []
    for frame in frameList:
        sourceOrder.extend(frame.Columns()) if axis == 0 else sourceOrder.extend(frame.Indices())
    sortedOrder = sorted.Columns() if axis == 0 else sorted.Indices()

    positions = []
    positionsSorted = []
    for i in sortedOrder:
        positions.append(sourceOrder.index(i))
        positionsSorted.append(sourceOrder.index(i))
    positionsSorted.sort()

    unsortedOrder = []
    for i in positionsSorted:
        unsortedOrder.append(sortedOrder[positions.index(i)])

    return sorted.ReorderCols(unsortedOrder) if axis == 0 else sorted.ReorderRows(unsortedOrder)

이 κΈ°λŠ₯은 kungfu!λΌλŠ” 개인 λͺ¨λ“ˆμ— ν¬ν•¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. λˆ„κ΅¬λ‚˜ μœ„μ˜ μ•Œκ³ λ¦¬μ¦˜μ„ μ±„νƒν•˜κ±°λ‚˜ https://github.com/jerryzhujian9/kungfu μ—μ„œ λ‚΄ λͺ¨λ“ˆμ„ λ³Ό 수

λ§ˆμ§€λ§‰μœΌλ‘œ 이 ν›Œλ₯­ν•œ λͺ¨λ“ˆμ— λŒ€ν•œ 개발 νŒ€μ˜ 노고에 κΉŠμ€ 감사λ₯Ό λ“œλ¦½λ‹ˆλ‹€!

이 λ™μž‘μ€ μ‹€μ œλ‘œ 맀우 μ˜ˆμƒμΉ˜ λͺ»ν•œ 것이며 저도 μš°μ—°νžˆ λ°œκ²¬ν–ˆμŠ΅λ‹ˆλ‹€.

 >>> df = pd.DataFrame()

>>> df['b'] = [1,2,3]
>>> df['c'] = [1,2,3]
>>> df['a'] = [1,2,3]
>>> print(df)
   b  c  a
0  1  1  1
1  2  2  2
2  3  3  3

[3 rows x 3 columns]
>>> df2 = pd.DataFrame({'a':[4,5]})
>>> df3 = pd.concat([df, df2])

μˆœμ§„ν•˜κ²Œλ„ μ—΄μ˜ μˆœμ„œκ°€ μœ μ§€λ  κ²ƒμœΌλ‘œ μ˜ˆμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€. λŒ€μ‹  열이 μ •λ ¬λ©λ‹ˆλ‹€.

>>> print(df3)
   a   b   c
0  1   1   1
1  2   2   2
2  3   3   3
0  4 NaN NaN
1  5 NaN NaN

[5 rows x 3 columns]

이것은 λ‹€μŒκ³Ό 같이 μ›λž˜ 열을 λ‹€μ‹œ μƒ‰μΈν™”ν•˜μ—¬ μˆ˜μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

>>> df4 = df3.reindex_axis(df.columns, axis=1)
>>> print(df4)
    b   c  a
0   1   1  1
1   2   2  2
2   3   3  3
0 NaN NaN  4
1 NaN NaN  5

[5 rows x 3 columns]

μ—¬μ „νžˆ 이 μžλ™ 정렬이 μˆ˜ν–‰λ˜κ³  λ‚΄κ°€ μ•„λŠ” ν•œ λΉ„ν™œμ„±ν™”ν•  수 μ—†λ‹€λŠ” 것이 직관적이지 μ•Šμ€ 것 κ°™μŠ΅λ‹ˆλ‹€.

λ‚˜λ„ 방금 이것을 μ ‘ν–ˆλ‹€.

new_data = pd.concat([churn_data, numerical_data])

DataFrame 생성:

     churn  Var1  Var10  Var100  Var101 
0      -1   NaN    NaN     NaN     NaN     
1      -1   NaN    NaN     NaN     NaN

숫자 DataFrame이 λ¨Όμ € μ •λ ¬λ˜μ§€ μ•Šκ³  μ—°κ²°λ˜λŠ” 것이 더 μžμ—°μŠ€λŸ¬μ›Œ 보일 κ²ƒμž…λ‹ˆλ‹€!!

κΈ€μŽ„, 이것은 μˆ˜μ •ν•΄μ•Ό ν•  μ•½κ°„μ˜ μž‘μ—…μž…λ‹ˆλ‹€. ν•˜μ§€λ§Œ ν’€ λ¦¬ν€˜μŠ€νŠΈκ°€ ν—ˆμš©λ©λ‹ˆλ‹€!

DataFrames μ—°κ²°ν•  λ•Œ 이와 λ™μΌν•œ λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. 이 λ¬Έμ œμ— λŒ€ν•΄ λͺ¨λ₯΄λŠ” 경우 μ•½κ°„ μ„±κ°€μ‹œμ§€λ§Œ μ‹€μ œλ‘œ λΉ λ₯Έ ν•΄κ²° 방법이 μžˆμŠ΅λ‹ˆλ‹€.

dfs 이 μ—°κ²°ν•˜λ €λŠ” DataFrames 의 λͺ©λ‘μ΄λΌκ³  κ°€μ •ν•˜λ©΄ μ›λž˜ μ—΄ μˆœμ„œλ₯Ό κ°€μ Έμ™€μ„œ λ‹€μ‹œ μž…λ ₯ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

df = pd.concat(dfs, axis=0)
df = df[dfs[0].columns]

참고둜 append κ°€ λ™μΌν•œ λ™μž‘μ„ μœ λ°œν•œλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

μ΄λŠ” μ „λ°˜μ μœΌλ‘œ κΈ°λ³Έ λ™μž‘μž…λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄, ν•¨μˆ˜ fλ₯Ό λ‹€μ–‘ν•œ 수의 열을 λ°˜ν™˜ν•˜λŠ” groupby()에 μ μš©ν•˜λ©΄ μž₯λ©΄ λ’€μ—μ„œ λ°œμƒν•˜λŠ” 연결도 열을 μžλ™ μ •λ ¬ν•©λ‹ˆλ‹€.

df.groupby(some_ts).apply(f)

μ—΄μ˜ μ•Œλ €μ§„ μˆœμ„œκ°€ 해석될 수 있기 λ•Œλ¬ΈμΌ 수 μžˆμŠ΅λ‹ˆλ‹€.

κ·ΈλŸ¬λ‚˜ 이것은 MultiIndices 및 MultiIndices의 λͺ¨λ“  κ³„μΈ΅μ—μ„œλ„ λ°œμƒν•©λ‹ˆλ‹€. λ”°λΌμ„œ level0 μ—΄κ³Ό λͺ¨λ“  λ§‰λŒ€κ°€ ν•˜λ‚˜μ˜ level1 열에 μΌμΉ˜ν•˜λŠ” 데이터 ν”„λ ˆμž„μ„ μ—°κ²°ν•  수 있으며 MultiIndices의 λͺ¨λ“  μˆ˜μ€€μ€ ν•˜λ‚˜μ˜ level0 μ—΄ λ‚΄μ—μ„œ ν•˜λ‚˜μ˜ 뢈일치둜 인해 μžλ™ μ •λ ¬λ©λ‹ˆλ‹€. λ‚˜λŠ” 그것이 λ°”λžŒμ§ν•˜λ‹€κ³  μƒκ°ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

λ„μ™€λ“œλ¦¬κ³  μ‹Άμ§€λ§Œ λΆˆν–‰νžˆλ„ 이 문제λ₯Ό ν•΄κ²°ν•˜λŠ” 것은 제 λŠ₯λ ₯ λ°–μž…λ‹ˆλ‹€. λͺ¨λ‘λ“€ 노고에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€.

이 κΈ°λŠ₯에 λŒ€ν•΄ +1

λ™μ˜ν•©λ‹ˆλ‹€, +1. 예기치 μ•Šμ€ 정렬이 항상 λ°œμƒν•©λ‹ˆλ‹€.

+1, 이것은 λΆˆμΎŒν•œ λ†€λΌμ›€μ΄μ—ˆμŠ΅λ‹ˆλ‹€!

+1, λ‚˜λŠ” append λ‹€μŒμ— 열을 μ •λ ¬ν•˜λŠ” 것을 μ‹«μ–΄ν•©λ‹ˆλ‹€.

λ‚˜μ—κ²Œλ„ +1.

μ—°κ²° 후에 μˆ˜λ™μœΌλ‘œ μž¬μ •λ ¬ν•˜κ³  μ‹Άμ—ˆλ”λΌλ„ λ‚΄ 데이터 ν”„λ ˆμž„μ—μ„œ 60개 μ΄μƒμ˜ μ—΄ 이름과 μœ„μΉ˜λ₯Ό μΈμ‡„ν•˜λ €κ³  ν•  λ•Œ:

 for id, value in enumerate(df.columns):
      print id, value

60개 μ΄μƒμ˜ λͺ¨λ“  열은 데이터 ν”„λ ˆμž„μ—μ„œμ˜ μ‹€μ œ μœ„μΉ˜κ°€ μ•„λ‹ˆλΌ μ•ŒνŒŒλ²³ μˆœμ„œλ‘œ 좜λ ₯λ©λ‹ˆλ‹€.

즉, μ—°κ²° ν›„ μž¬μ •λ ¬ν•˜λ €λ©΄ 60개 μ—΄ λͺ©λ‘μ„ μˆ˜λ™μœΌλ‘œ μž…λ ₯ν•΄μ•Ό ν•©λ‹ˆλ‹€. μ•„μ•Ό.

λ‚΄κ°€ 여기에 μžˆλŠ” λ™μ•ˆ λ‚΄κ°€ λˆ„λ½λœ μ—΄ 이름과 μœ„μΉ˜λ₯Ό 인쇄할 수 μžˆλŠ” μ‚¬λžŒμ΄ μžˆμŠ΅λ‹ˆκΉŒ?

이 κΈ°λŠ₯에 λŒ€ν•΄ +1, 방금 λ™μΌν•œ 거래λ₯Ό λ§Œλ‚¬μŠ΅λ‹ˆλ‹€.

@summerela μ—΄ 인덱슀λ₯Ό κ°€μ Έμ˜¨ λ‹€μŒ μ›λž˜ μ—΄ 인덱슀λ₯Ό μ‚¬μš©ν•˜μ—¬ μƒˆ 데이터 ν”„λ ˆμž„μ„ λ‹€μ‹œ μΈλ±μ‹±ν•©λ‹ˆλ‹€.

# assuming you have two dataframes, `df_train` & `df_test` (with the same columns) 
# that you want to concatenate

# get the columns from one of them
all_columns = df_train.columns

# concatenate them
df_concat = pd.concat([df_train,
                       df_test])

# finally, re-index the new dataframe using the original column index
df_concat = df_concat.ix[:, all_columns]

λ°˜λŒ€λ‘œ, μ—΄μ˜ 더 μž‘μ€ ν•˜μœ„ 집합을 λ‹€μ‹œ 인덱싱해야 ν•˜λŠ” 경우 λ‚΄κ°€ λ§Œλ“  이 ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. μƒλŒ€ μΈλ±μŠ€λ‘œλ„ μž‘λ™ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄ 열을 데이터 ν”„λ ˆμž„μ˜ 끝으둜 μ΄λ™ν•˜κ³  μ‹Άμ§€λ§Œ 슀크립트의 이전 처리 단계 후에 남아 μžˆλŠ” μ—΄μ˜ μˆ˜κ°€ ν™•μ‹€ν•˜μ§€ μ•Šμ€ 경우(예: 뢄산이 μ—†λŠ” 열을 μ‚­μ œν•˜λŠ” 경우) μƒλŒ€ 인덱슀 μœ„μΉ˜λ₯Ό new_indices --> new_indices = [-1] 전달할 수 있으며 λ‚˜λ¨Έμ§€λŠ” μ•Œμ•„μ„œ μ²˜λ¦¬ν•©λ‹ˆλ‹€.

def reindex_columns(dframe=None, columns=None, new_indices=None):
    """
    Reorders the columns of a dataframe as specified by
    `reorder_indices`. Values of `columns` should align with their
    respective values in `new_indices`.

    `dframe`: pandas dataframe.

    `columns`: list,pandas.core.index.Index, or numpy array; columns to
    reindex.

    `reorder_indices`: list of integers or numpy array; indices
    corresponding to where each column should be inserted during
    re-indexing.
    """
    print("Re-indexing columns.")
    try:
        df = dframe.copy()

        # ensure parameters are of correct type and length
        assert isinstance(columns, (pd.core.index.Index,
                                    list,
                                    np.array)),\
        "`columns` must be of type `pandas.core.index.Index` or `list`"

        assert isinstance(new_indices,
                          list),\
        "`reorder_indices` must be of type `list`"

        assert len(columns) == len(new_indices),\
        "Length of `columns` and `reorder_indices` must be equal"

        # check for negative values in `new_indices`
        if any(idx < 0 for idx in new_indices):

            # get a list of the negative values
            negatives = [value for value
                         in new_indices
                         if value < 0]

            # find the index location for each negative value in
            # `new_indices`
            negative_idx_locations = [new_indices.index(negative)
                                      for negative in negatives]

            # zip the lists
            negative_zipped = list(zip(negative_idx_locations,
                                       negatives))

            # replace the negatives in `new_indices` with their
            # absolute position in the index
            for idx, negative in negative_zipped:
                new_indices[idx] = df.columns.get_loc(df.columns[
                                                          negative])

        # re-order the index now
        # get all columns
        all_columns = df.columns

        # drop the columns that need to be re-indexed
        all_columns = all_columns.drop(columns)

        # now re-insert them at the specified locations
        zipped_columns = list(zip(new_indices,
                                  columns))

        for idx, column in zipped_columns:
            all_columns = all_columns.insert(idx,
                                             column)
        # re-index the dataframe
        df = df.ix[:, all_columns]

        print("Successfully re-indexed dataframe.")

    except Exception as e:
        print(e)
        print("Could not re-index columns. Something went wrong.")

    return df

νŽΈμ§‘: μ‚¬μš©λ²•μ€ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

# move 'Column_1' to the end, move 'Column_2' to the beginning
df = reindex_columns(dframe=df,
                     columns=['Column_1', 'Column_2'],
                     new_indices=[-1, 0])

μ–ΈκΈ‰λ˜μ§€ μ•Šμ€ 극단적인 경우(각각 κ³ μœ ν•œ 열을 ν¬ν•¨ν•˜λŠ” 데이터 ν”„λ ˆμž„ κ²°ν•©)μ—μ„œ 이 문제(0.13.1 포함)κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. μ—΄ μ΄λ¦„μ˜ μˆœμ§„ν•œ μž¬ν• λ‹Ήμ΄ μž‘λ™ν•˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

dat = pd.concat([out_dust, in_dust, in_air, out_air])
dat.columns = [out_dust.columns + in_dust.columns + in_air.columns + out_air.columns]

열은 μ—¬μ „νžˆ β€‹β€‹μ •λ ¬λ©λ‹ˆλ‹€. λͺ©λ‘μ„ μ‚¬μš©ν•˜λ©΄ 쀑간에 ν•΄κ²°λ˜μ§€λ§Œ:

νŽΈμ§‘ : λ„ˆλ¬΄ 빨리 λ§ν–ˆμ–΄..


후속 쑰치: fwiw, 단일 객체에 λŒ€ν•œ .join 호좜둜 μ—΄ μˆœμ„œλ₯Ό μœ μ§€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

df1.join([df2, df3]) # sorts columns
df1.join(df2).join(df3) # column order retained

μ—΄ μˆœμ„œ 지정에 λŒ€ν•œ dataFrame을 생성할 λ•Œ λ§€κ°œλ³€μˆ˜κ°€ μžˆμ„ 수 μžˆμŠ΅λ‹ˆκΉŒ? 주문처럼=거짓. 정말 κ°μ‚¬ν•©λ‹ˆλ‹€

μ‚¬μ „μ—μ„œ 데이터 ν”„λ ˆμž„μ„ μƒμ„±ν•˜λŠ” λ™μ•ˆ 방금 이 λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. λ‚˜λ₯Ό μ™„μ „νžˆ λ†€λΌκ²Œ ν•˜κ³  λ°˜μ§κ΄€μ μ΄μ—ˆκ³  λ‚΄ λͺ¨λ“  λͺ©μ μ„ μ’Œμ ˆμ‹œμΌ°μŠ΅λ‹ˆλ‹€...

μ—΄ 이름은 λͺ…확성을 μœ„ν•΄ μ‚¬μš©ν•΄μ•Ό ν•˜λ©° μ„œλ‘œ κ°€κΉŒμš΄ μ—΄μ˜ μœ„μΉ˜λŠ” 일관성을 μœ μ§€ν•˜κΈ° μœ„ν•΄ μ‚¬μš©μžκ°€ 쑰직적으둜 μ„ νƒν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

@patricktokeeff
join 에 λŒ€ν•œ 포인터λ₯Ό μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. Series κ°μ²΄μ—λŠ” ν•΄λ‹Ή λ©”μ„œλ“œκ°€ μ—†μœΌλ―€λ‘œ κ²°κ΅­ ν•¨μˆ˜λ₯Ό μž‘μ„±ν•˜κ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

def concat_fixed(ndframe_seq, **kwargs):
    """Like pd.concat but fixes the ordering problem.

    Converts Series objects to DataFrames to access join method
    Use kwargs to pass through to repeated join method
    """
    indframe_seq = iter(ndframe_seq)
    # Use the first ndframe object as the base for the final
    final_df = pd.DataFrame(next(indframe_seq))
    for dataframe in indframe_seq:
        if isinstance(dataframe, pd.Series):
            dataframe = pd.DataFrame(dataframe)
        # Iteratively build final table
        final_df = final_df.join(dataframe, **kwargs)
    return final_df

이에 λŒ€ν•œ νš¨μœ¨μ„±μ€ μ–΄λ–»μŠ΅λ‹ˆκΉŒ?

2017λ…„ 8μ›” 30일 μˆ˜μš”μΌ μ˜€ν›„ 1μ‹œ 58λΆ„, Bryce Guinta [email protected]
썼닀:

@patricktokeeffe https://github.com/patricktokeeffe
κ°€μž…ν•  포인터λ₯Ό μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. μ‹œλ¦¬μ¦ˆ κ°μ²΄μ—λŠ” ν•΄λ‹Ή λ©”μ†Œλ“œκ°€ μ—†μœΌλ―€λ‘œ
λ‚˜λŠ” κ²°κ΅­ ν•¨μˆ˜λ₯Ό μž‘μ„±ν–ˆλ‹€.

def concat_fixed(ndframe_seq, **kwargs):
"""pd.concatκ³Ό λΉ„μŠ·ν•˜μ§€λ§Œ μ£Όλ¬Έ 문제λ₯Ό μˆ˜μ •ν•©λ‹ˆλ‹€.

Converts Series objects to DataFrames to access join method
Use kwargs to pass through to repeated join method
"""
indframe_seq = iter(ndframe_seq)
# Use the first ndframe object as the base for the final
final_df = pd.DataFrame(next(indframe_seq))
for dataframe in indframe_seq:
    if isinstance(dataframe, pd.Series):
        # Convert Series objects into DataFrames since
        # series objects do not have a join method
        dataframe = pd.DataFrame(dataframe)
    # Iteratively build final table
    final_df = final_df.join(dataframe, **kwargs)
return final_df

β€”
당신이 λŒ“κΈ€μ„ λ‹¬μ•˜κΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/pandas-dev/pandas/issues/4588#issuecomment-326086636 ,
λ˜λŠ” μŠ€λ ˆλ“œ μŒμ†Œκ±°
https://github.com/notifications/unsubscribe-auth/AG999MucF-NH5vHuKe-Zczq-jy9ziYkRks5sdbDogaJpZM4A6TeA
.

@MikeTam1021

λ‚˜λŠ” 그것을 atm으둜 λ²€μΉ˜λ§ˆν‚Ήν•˜μ§€ μ•Šμ„ κ²ƒμ΄μ§€λ§Œ, λ‚˜λŠ” 그것이 λ‹Ήμ‹ μ˜ ndframes의 크기, κ·Έ μ–‘μ˜ ν•¨μˆ˜μΌ 것이라고 μƒκ°ν•©λ‹ˆλ‹€. 각 ndframe에 λŒ€ν•΄ μƒˆ 데이터 ν”„λ ˆμž„μ„ μƒμ„±ν•˜λ―€λ‘œ pd.concat 보닀 훨씬 덜 효율적이라고 μƒκ°ν•©λ‹ˆλ‹€.

λ‚΄ λͺ©μ μ—λŠ” 잘 μž‘λ™ν•˜μ§€λ§Œ 각 ndframe(μ•½ 10 2 )에 λŒ€ν•΄ μ†ŒλŸ‰μ˜ ndframes (μ•½ 10 1 ) 및 비ꡐ적 적은 μ–‘μ˜ records λ₯Ό μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

λ‚΄ λͺ©ν‘œλŠ” λͺ¨λ“  ndframe에 μ§€μ •λœ λ ˆμ½”λ“œμ— λŒ€ν•œ 데이터가 ν¬ν•¨λ˜μ–΄ μžˆμ§€ μ•Šλ”λΌλ„ ν•΄λ‹Ή λ ˆμ½”λ“œμ˜ μˆœμ„œλ₯Ό μœ μ§€ν•˜λ©΄μ„œ λͺ¨λ“  데이터 ν”„λ ˆμž„μ˜ λͺ¨λ“  λ ˆμ½”λ“œλ₯Ό ν¬ν•¨ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

μ—΄ μˆœμ„œλ₯Ό μ΅œλŒ€ν•œ μœ μ§€ν•˜λŠ” 것이 concat()의 κΈ°λ³Έ λ™μž‘μ΄ μ•„λ‹Œ 이유λ₯Ό μ•Œ 수 μ—†μŠ΅λ‹ˆλ‹€.

λ‚΄ ν•΄κ²° 방법은 Itertools Recipes의 unique_everseen λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

columns = unique_everseen([column for df in dfs for column in df.columns])
df = pd.concat(dfs)[columns]

이 μŠ€λ ˆλ“œμ˜ μƒνƒœμ— λŒ€ν•œ μ—…λ°μ΄νŠΈκ°€ μžˆμŠ΅λ‹ˆκΉŒ? ν˜„μž¬ 버전 0.22.0을 μ‚¬μš©ν•˜κ³  있으며 μ—¬μ „νžˆ μ μ ˆν•œ μ†”λ£¨μ…˜μ΄ μ—†λŠ” 것 κ°™μŠ΅λ‹ˆλ‹€. μ—¬κΈ°μ—μ„œ λ―Έλ£¨λŠ” 것이 κ½€ 문제인 것 κ°™μŠ΅λ‹ˆλ‹€...

λ˜ν•œ axis=1 와 같이 열을 μ—°κ²°ν•  λ•Œ μœ μ‚¬ν•œ λ™μž‘μ„ 찾을 수 μžˆμ§€λ§Œ 사전에 데이터 ν”„λ ˆμž„μ„ 전달할 λ•Œλ§Œ 찾을 수 μžˆλ‹€λŠ” 점에 μ£Όλͺ©ν•˜κ³  μ‹ΆμŠ΅λ‹ˆλ‹€.

>>> df4a = DataFrame(columns=['C','B','D','A'], data=np.random.randn(3,4))
>>> df4b = DataFrame(columns=['C','B','D','A'], data=np.random.randn(3,4))
>>> df5  = DataFrame(columns=['C','B','E','D','A'], data=np.random.randn(3, 5))

>>> pd.concat([df4a, df5], axis=1).columns
Index(['C', 'B', 'D', 'A', 'C', 'B', 'E', 'D', 'A'], dtype='object')
>>> pd.concat({'df4a': df4a, 'df4b': df4b}, axis=1).columns.levels
FrozenList([['df4a', 'df4b'], ['C', 'B', 'D', 'A']])
>>> pd.concat({'df4a': df4a, 'df5': df5}, axis=1).columns.levels
FrozenList([['df4a', 'df5'], ['A', 'B', 'C', 'D', 'E']])

이 μŠ€λ ˆλ“œμ˜ μƒνƒœμ— λŒ€ν•œ μ—…λ°μ΄νŠΈκ°€ μžˆμŠ΅λ‹ˆκΉŒ?

아직 μ—΄λ € μžˆμŠ΅λ‹ˆλ‹€.

μ—¬κΈ°μ—μ„œ λ―Έλ£¨λŠ” 것이 κ½€ 문제인 것 κ°™μŠ΅λ‹ˆλ‹€...

미루닀? μš°λ¦¬μ—κ²ŒλŠ” λ§Žμ€ λ―Έν•΄κ²° λ¬Έμ œκ°€ μžˆμŠ΅λ‹ˆλ‹€. λ‹€μŒ λ¦΄λ¦¬μŠ€μ—μ„œ 이 λ¬Έμ œκ°€ ν•΄κ²°λ˜λ„λ‘ ν•˜λ €λ©΄ PR을 μž‘μ„±ν•˜λŠ” 것이 κ°€μž₯ μ’‹μŠ΅λ‹ˆλ‹€. μ‹œμž‘ν•˜λŠ” 데 도움이 ν•„μš”ν•˜λ©΄ μ•Œλ €μ£Όμ‹­μ‹œμ˜€.

@jtratner : 맨 μœ„μ˜ μ˜ˆμ—μ„œ λͺ…ν™•ν•˜μ§€ μ•Šμ€ 경우 μˆœμ„œλŠ” λ‹€μŒκ³Ό 같을 κ²ƒμœΌλ‘œ μ˜ˆμƒν•©λ‹ˆλ‹€.

  • 곡유 μ—΄, μ •λ ¬λ˜μ§€ μ•ŠμŒ
  • df1에 κ³ μœ ν•œ μ—΄, μ •λ ¬λ˜μ§€ μ•ŠμŒ(즉, df1μ—μ„œ λ°œμƒν•˜λŠ” μˆœμ„œλŒ€λ‘œ)
  • df2에 κ³ μœ ν•œ μ—΄, μ •λ ¬λ˜μ§€ μ•ŠμŒ(즉, df2μ—μ„œ λ°œμƒν•˜λŠ” μˆœμ„œλŒ€λ‘œ)

이것은 SQLκ³Ό 같은 λ‹€λ₯Έ νŒ¨ν‚€μ§€λ‚˜ μ–Έμ–΄μ—μ„œ 얻을 수 μžˆλŠ” κ²ƒμž…λ‹ˆλ‹€. μ›μΉ˜ μ•ŠλŠ” μžλ™ 정렬이 μžˆμ–΄μ„œλŠ” μ•ˆ λ©λ‹ˆλ‹€. μ‚¬μš©μžκ°€ μ—΄ 이름을 μ •λ ¬ν•˜λ €λŠ” 경우 μˆ˜λ™μœΌλ‘œ μ •λ ¬ν•˜λ„λ‘ ν•˜μ‹­μ‹œμ˜€.

μ–˜λ“€μ•„, 2가지. 1) νŒ¬λ”μ— μ˜€μ‹  것을 ν™˜μ˜ν•©λ‹ˆλ‹€! 사전과 같은 더 λ§Žμ€ 파이썬 κΈ°λ³Έ μœ ν˜•μ„ μ‚¬μš©ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. 파이썬(λ˜λŠ” λͺ¨λ“  μ–Έμ–΄)을 SQL둜 λ°”κΎΈλ €λŠ” μ‹œλ„λ₯Ό μ€‘λ‹¨ν•˜μ‹­μ‹œμ˜€. 2) 이것은 기술적으둜 버그가 μ•„λ‹™λ‹ˆλ‹€. 그것은 단지 μ½”λ“œμ˜ μ›μΉ˜ μ•ŠλŠ” 효과일 λΏμž…λ‹ˆλ‹€. νŒ¨ν‚€μ§€μ˜ μ»¨ν…μŠ€νŠΈ μ™ΈλΆ€μ—μ„œ μ‰½κ²Œ 극볡할 수 있으며 μ—¬κΈ°μ—μ„œ λˆ„κ΅°κ°€κ°€ 슀슀둜 ν•΄κ²°ν•˜μ§€ μ•ŠλŠ” ν•œ 이것이 정닡이라고 μƒκ°ν•©λ‹ˆλ‹€.

@MikeTam1021 νŒ¨ν‚€μ§€ μ»¨ν…μŠ€νŠΈ μ™ΈλΆ€μ—μ„œ 이λ₯Ό κ·Ήλ³΅ν•˜λŠ” 방법을 μ„€λͺ…ν•΄μ£Όμ„Έμš”. 감사 ν•΄μš”.

이 μŠ€λ ˆλ“œμ˜ μ‚¬λžŒλ“€μ΄ λ…Όμ˜ν•œ λ‚΄μš©μ΄ λ°”λ‘œ 이것이라고 ν™•μ‹ ν•©λ‹ˆλ‹€. μœ„μ˜ λ§Žμ€ 쒋은 μ†”λ£¨μ…˜μ΄ μž‘λ™ν•΄μ•Ό ν•©λ‹ˆλ‹€.

@MikeTam1021 νŒ¬λ”λ₯Ό SQL둜 λ°”κΎΈλŠ” 것은 μ•„λ‹ˆμ§€λ§Œ(천ꡭ κΈˆμ§€!) λ‹€μŒκ³Ό 같이 더 λ™μ˜ν•  수 μ—†μŠ΅λ‹ˆλ‹€.

μ›μΉ˜ μ•ŠλŠ” μžλ™ 정렬이 μžˆμ–΄μ„œλŠ” μ•ˆ λ©λ‹ˆλ‹€. μ‚¬μš©μžκ°€ μ—΄ 이름을 μ •λ ¬ν•˜λ €λŠ” 경우 μˆ˜λ™μœΌλ‘œ μ •λ ¬ν•˜λ„λ‘ ν•˜μ‹­μ‹œμ˜€.

DataFramesλ₯Ό μ—°κ²°ν•˜λŠ” 것은 "μ„œλ‘œ λ‚˜λž€νžˆ μ“°κΈ°"와 같은 효과λ₯Ό κ°€μ Έμ•Ό ν•˜λ©°, κ·Έ μ•”μ‹œμ  정렬은 ν™•μ‹€νžˆ μ΅œμ†Œ λ†€λΌμ›€μ˜ 원칙을 μœ„λ°˜ν•©λ‹ˆλ‹€.

λ‚˜λŠ” λ™μ˜ν•œλ‹€. 그러면 μ•ˆλ©λ‹ˆλ‹€. λ˜ν•œ μˆœμˆ˜ν•œ 컴퓨터 과학이 μ•„λ‹Œ SQL λ°©μ‹μ˜ 열에 λŒ€ν•œ μˆœμ„œλ₯Ό κ°€μ •ν•©λ‹ˆλ‹€. 데이터가 어디에 μžˆλŠ”μ§€ μ •ν™•νžˆ μ•Œμ•„μ•Ό ν•©λ‹ˆλ‹€.

λ‚˜λŠ” 이것과 λ‹€λ₯Έ λ§Žμ€ 문제λ₯Ό λ°œκ²¬ν•œ 후에 더 이상 νŒ¬λ”λ₯Ό 거의 μ‚¬μš©ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 그것은 λ‚˜λ₯Ό 더 λ‚˜μ€ ν”„λ‘œκ·Έλž˜λ¨Έλ‘œ λ§Œλ“€μ—ˆλ‹€.

이것에 +1

이것은 λ‚˜λ₯Ό μœ„ν•΄ μž‘λ™ν•©λ‹ˆλ‹€.

cols = list(df1)+list(df2)
df1 = pd.concat([df1, df2])
df1 = df1.loc[:, cols]

이 νŒ¨μΉ˜κ°€ μ–΄λ–»κ²Œ λ°°ν¬λ˜λŠ”μ§€μ— λŒ€ν•΄ κ°œμ†Œλ¦¬λ₯Ό ν•΄μ•Ό ν•©λ‹ˆλ‹€. concat 의 κΈ°λŠ₯ μ„œλͺ…을 λ™μ‹œμ— λ³€κ²½ν•˜κ³  μ‚¬μš©λ²•μ— λŒ€ν•œ κ²½κ³ λ₯Ό λ„μž…ν–ˆμŠ΅λ‹ˆλ‹€. λͺ¨λ‘ λ™μΌν•œ 컀밋 내에 μžˆμŠ΅λ‹ˆλ‹€.

κ·Έκ²ƒμ˜ λ¬Έμ œλŠ” μš°λ¦¬κ°€ μ—¬λŸ¬ μ„œλ²„μ—μ„œ νŒλ‹€λ₯Ό μ‚¬μš©ν•˜κ³  λͺ¨λ“  μ„œλ²„μ— 항상 λ˜‘κ°™μ€ νŒλ‹€ 버전이 μžˆλ‹€κ³  보μž₯ν•  수 μ—†λ‹€λŠ” κ²ƒμž…λ‹ˆλ‹€. λ”°λΌμ„œ 이제 μš°λ¦¬λŠ” 이전에 λ³Έ 적이 μ—†λŠ” ν”„λ‘œκ·Έλž¨μ˜ κ²½κ³ λ₯Ό λ³΄λŠ” 기술적인 μ‚¬μš©μžκ°€ μ€„μ–΄λ“€μ—ˆκ³  κ²½κ³ κ°€ 문제의 징후인지 ν™•μ‹€ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

κ²½κ³ κ°€ λ°œμƒν•œ μœ„μΉ˜λ₯Ό μ‰½κ²Œ 식별할 수 μžˆμ§€λ§Œ 이전 λ²„μ „μ˜ νŒ¬λ”λ₯Ό μ‹€ν–‰ν•˜λŠ” μ„œλ²„μ—μ„œ ν”„λ‘œκ·Έλž¨μ΄ 쀑단될 수 μžˆμœΌλ―€λ‘œ μ œμ•ˆλœ μ˜΅μ…˜ 쀑 ν•˜λ‚˜λ₯Ό μΆ”κ°€ν•  수 μ—†μŠ΅λ‹ˆλ‹€.

μ •λ ¬ κΈ°λŠ₯을 0.23에 λ„£κ³  이후 버전에 κ²½κ³ λ₯Ό μΆ”κ°€ν–ˆλ‹€λ©΄ 더 μ’‹μ•˜μ„ κ²ƒμž…λ‹ˆλ‹€. κ·Έ 고톡을 μ•Œκ³  μžˆμ§€λ§Œ μ‚¬μš©μžκ°€ λͺ¨λ“  배포λ₯Ό μ΅œμ‹  μ½”λ“œλ‘œ μ¦‰μ‹œ μ—…λ°μ΄νŠΈν•  수 μžˆλ‹€κ³  κ°€μ •ν•˜λŠ” 것은 λ‹€μ†Œ λΆˆμΎŒν•©λ‹ˆλ‹€.

이 경고에 λŒ€ν•œ μ „μ—­ ν•„ν„°λ₯Ό μ„€μ •ν•œ λ‹€μŒ
λͺ¨λ‘κ°€ μ—…κ·Έλ ˆμ΄λ“œλ˜λ©΄ λ“œλ‘­ν•˜μ‹­μ‹œμ˜€.

κΈ°λŠ₯μ μœΌλ‘œλŠ” λ˜‘κ°™μ£ ?

2018λ…„ 10μ›” 4일 λͺ©μš”일 μ˜€μ „ 9:18 DavidEscott [email protected]μ—μ„œ λ‹€μŒκ³Ό 같이 μΌμŠ΅λ‹ˆλ‹€.

이 νŒ¨μΉ˜κ°€ μ–΄λ–»κ²Œ λ°°ν¬λ˜λŠ”μ§€μ— λŒ€ν•΄ κ°œμ†Œλ¦¬λ₯Ό ν•΄μ•Ό ν•©λ‹ˆλ‹€. 당신은
concat의 κΈ°λŠ₯ μ„œλͺ…을 λ™μ‹œμ— λ³€κ²½ν•˜κ³  λ„μž…ν–ˆμŠ΅λ‹ˆλ‹€.
μ‚¬μš©λ²•μ— λŒ€ν•œ κ²½κ³ . λͺ¨λ‘ λ™μΌν•œ 컀밋 내에 μžˆμŠ΅λ‹ˆλ‹€.

λ¬Έμ œλŠ” μš°λ¦¬κ°€ μ—¬λŸ¬ μ„œλ²„μ—μ„œ pandasλ₯Ό μ‚¬μš©ν•˜κ³ 
λͺ¨λ“  μ„œλ²„μ— μ™„μ „νžˆ λ™μΌν•œ λ²„μ „μ˜ νŒ¬λ”κ°€ μžˆμŒμ„ 보μž₯ν•©λ‹ˆλ‹€.
νƒ€μž„μŠ€. λ”°λΌμ„œ 이제 ν”„λ‘œκ·Έλž¨μ—μ„œ κ²½κ³ κ°€ ν‘œμ‹œλ˜λŠ” 기술 μ‚¬μš©μžκ°€ μ€„μ–΄λ“­λ‹ˆλ‹€.
그듀은 전에 λ³Έ 적이 μ—†μœΌλ©° κ²½κ³ κ°€ 경고의 ν‘œμ‹œμΈμ§€ λΆˆν™•μ‹€ν•©λ‹ˆλ‹€.
문제.

κ²½κ³ κ°€ λ°œμƒν•˜λŠ” μœ„μΉ˜λ₯Ό μ‰½κ²Œ 식별할 수 μžˆμ§€λ§Œ μΆ”κ°€ν•  μˆ˜λŠ” μ—†μŠ΅λ‹ˆλ‹€.
μ œμ•ˆλœ μ˜΅μ…˜ 쀑 ν•˜λ‚˜λ₯Ό μ„ νƒν•˜λ©΄ ν”„λ‘œκ·Έλž¨μ΄ 쀑단될 수 μžˆμœΌλ―€λ‘œ
이전 λ²„μ „μ˜ νŒ¬λ”λ₯Ό μ‹€ν–‰ν•˜λŠ” μ„œλ²„.

μ •λ ¬ κΈ°λŠ₯을 μΆ”κ°€ν–ˆλ‹€λ©΄ 더 μ’‹μ•˜μ„ κ²ƒμž…λ‹ˆλ‹€.
0.23 및 일뢀 이후 버전에 κ²½κ³ λ₯Ό μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€. κ·Έ 고톡을 μ•Œμ§€λ§Œ
μ‚¬μš©μžκ°€ λͺ¨λ“  ν•­λͺ©μ„ μ¦‰μ‹œ μ—…λ°μ΄νŠΈν•  수 μžˆλ‹€κ³  κ°€μ •ν•˜λŠ” 것은 λ‹€μ†Œ λΆˆμΎŒν•©λ‹ˆλ‹€.
μ΅œμ‹  μ½”λ“œμ— λ°°ν¬ν•©λ‹ˆλ‹€.

β€”
μ—΄κΈ°/λ‹«κΈ° μƒνƒœλ₯Ό μˆ˜μ •ν–ˆκΈ° λ•Œλ¬Έμ— 이 λ©”μ‹œμ§€κ°€ ν‘œμ‹œλ©λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/pandas-dev/pandas/issues/4588#issuecomment-427036391 ,
λ˜λŠ” μŠ€λ ˆλ“œ μŒμ†Œκ±°
https://github.com/notifications/unsubscribe-auth/ABQHItEhYfv5kqB-R-pDX4zyIh45hF7kks5uhhiWgaJpZM4A6TeA
.

@TomAugspurger 우리 μΈ‘μ—μ„œ 이λ₯Ό μ²˜λ¦¬ν•  수 μžˆλŠ” λ‹€μ–‘ν•œ 방법이 μžˆμŠ΅λ‹ˆλ‹€. ν™•μ‹€νžˆ 필터링 κ²½κ³ λŠ” ν•˜λ‚˜μž…λ‹ˆλ‹€. κ²½κ³  ν•„ν„°μ˜ λ©”μ»€λ‹ˆμ¦˜μ΄ μ•½κ°„ λͺ»μƒκ²ΌκΈ° λ•Œλ¬Έμ— 쒋지 μ•ŠμŠ΅λ‹ˆλ‹€...

  1. μ—¬λŸ¬ ν”„λ‘œκ·Έλž¨μ— ν•„ν„°λ₯Ό μΆ”κ°€ν•΄μ•Ό ν•©λ‹ˆλ‹€.
  2. 필터링할 νŠΉμ • κ²½κ³ λ₯Ό μ§€μ •ν•˜λŠ” 쒋은 방법은 μ•„λ‹™λ‹ˆλ‹€.

    • λͺ¨λ“ˆκ³Ό lineno둜 필터링할 수 μžˆμ§€λ§Œ μ•ˆμ •μ μΈ μ°Έμ‘°λŠ” μ•„λ‹™λ‹ˆλ‹€.

    • λͺ¨λ“ˆ 및 FutureWarning 필터링할 수 μžˆμ§€λ§Œ νŒ¬λ”μ—μ„œ μ „ν˜€ κ²½κ³ λ₯Ό 받지 μ•Šκ³  λ‹€λ₯Έ λ³€κ²½ 사항에 λ†€λž„ κ²ƒμž…λ‹ˆλ‹€.

    • λ˜λŠ” κΈ΄ μ—¬λŸ¬ 쀄 λ©”μ‹œμ§€λ‘œ 필터링할 수 μžˆμŠ΅λ‹ˆλ‹€.

  3. 그런 λ‹€μŒ λͺ¨λ“  것이 μ—…κ·Έλ ˆμ΄λ“œλ˜μ–΄ 더 이상 μ€‘μš”ν•˜μ§€ μ•Šμ„ λ•Œ ν•΄λ‹Ή ν•„ν„°λ₯Ό μ œκ±°ν•˜λŠ” 것을 μžŠμ§€ λ§ˆμ‹­μ‹œμ˜€.

μ–΄μ¨Œλ“  warnings λͺ¨λ“ˆμ˜ 결함은 ν™•μ‹€νžˆ λ‚΄κ°€ pandas νŒ€μ˜ λ°œμ•„λž˜ 놓을 수 μžˆλŠ” 것이 μ•„λ‹™λ‹ˆλ‹€.

μš°λ¦¬κ°€ μ‰½κ²Œ μ—…κ·Έλ ˆμ΄λ“œν•  수 μ—†λŠ” 였래된 μ„œλ²„λ₯Ό 가지고 μžˆλŠ” 것도 λ‹Ήμ‹ μ˜ 잘λͺ»μ΄ μ•„λ‹™λ‹ˆλ‹€. κ·Έλž˜μ„œ 그것이 μ œκ°€ ν•  수 μžˆλŠ” λ‹€λ₯Έ μΌμž…λ‹ˆλ‹€(κ·Έλƒ₯ λͺ¨λ“  망할 배포λ₯Ό μ—…κ·Έλ ˆμ΄λ“œν•˜μ‹­μ‹œμ˜€). ꢁ극적으둜 μ €λŠ” κ·Έλ ‡κ²Œ ν•΄μ•Ό ν•˜λ©° 배포λ₯Ό κΈ΄λ°€ν•˜κ²Œ μœ μ§€ν•˜λ €κ³  λ…Έλ ₯ν•˜λŠ” 것이 제 μ±…μž„μ΄λΌλŠ” 것을 μ•Œκ³  μžˆμŠ΅λ‹ˆλ‹€.

이전에 μ§€μ •λ˜μ§€ μ•Šμ€ API에 이 μ •λ ¬ μ˜΅μ…˜μ„ μΆ”κ°€ν–ˆμ§€λ§Œ λ™μ‹œμ— ν”„λ‘œκ·Έλž˜λ¨Έμ—κ²Œ κ²½κ³ λ₯Ό λ˜μ§€λ©΄μ„œ μ‚¬μš©μžκ°€ λ³Ό 수 μžˆλŠ” μ΅œμ’… λ™μž‘μ˜ κ°€λŠ₯ν•œ λ³€κ²½ 사항에 λŒ€ν•΄ μš°λ €ν•˜κ³  μžˆλ‹€λŠ” 것이 μ œκ²ŒλŠ” 쑰금 μ΄μƒν•˜κ²Œ λ³΄μž…λ‹ˆλ‹€. λ‘˜ λ‹€ 경고와 μ •λ ¬ λ™μž‘μ˜ μ œμ•ˆλœ 변경은 λ‚΄ μ±…μ—μ„œ 심각도가 λ‹€λ₯Έ "μ‚¬μš©μžκ°€ λ³Ό 수 μžˆλŠ” λ™μž‘"을 κ΅¬μ„±ν•©λ‹ˆλ‹€.

SO 에 λŒ€ν•œ κ΄€λ ¨ μ§ˆλ¬Έμ— λ‹΅λ³€ν–ˆμŠ΅λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰