<jupyter_start><jupyter_text>컬럼 이름 출력을 하고싶은 경우 df.columns 컬럼 개수 출력을 하고싶은 경우 len(df.columns)<jupyter_code>print(trn.columns)
print(len(trn.columns))<jupyter_output>Index(['fecha_dato', 'ncodpers', 'ind_empleado', 'pais_residencia', 'sexo',
       'age', 'fecha_alta', 'ind_nuevo', 'antiguedad', 'indrel',
       'ult_fec_cli_1t', 'indrel_1mes', 'tiprel_1mes', 'indresi', 'indext',
       'conyuemp', 'canal_entrada', 'indfall', 'tipodom', 'cod_prov',
       'nomprov', 'ind_actividad_cliente', 'renta', 'segmento',
       'ind_ahor_fin_ult1', 'ind_aval_fin_ult1', 'ind_cco_fin_ult1',
       'ind_cder_fin_ult1', 'ind_cno_fin_ult1', 'ind_ctju_fin_ult1',
       'ind_ctma_fin_ult1', 'ind_ctop_fin_ult1', 'ind_ctpp_fin_ult1',
       'ind_deco_fin_ult1', 'ind_deme_fin_ult1', 'ind_dela_fin_ult1',
       'ind_ecue_fin_ult1', 'ind_fond_fin_ult1', 'ind_hip_fin_ult1',
       'ind_plan_fin_ult1', 'ind_pres_fin_ult1', 'ind_reca_fin_ult1',
       'ind_tjcr_fin_ult1', 'ind_valo_fin_ult1', 'ind_viv_fin_ult1',
       'ind_nomina_ult1', 'ind_nom_pens_ult1', 'ind_recibo_ult1'],
      dtype='object')
48<jupyter_text>고유한 값이 어떻게 되는지 알고 싶다면np.unique(df[col].astype(str))col값을 변수로 두고 for문을 돌리면 됩니다-!<jupyter_code>np.unique(trn["sexo"].astype(str))<jupyter_output><empty_output><jupyter_text>그래프를 그릴 때 도화지를 어떻게 그릴것인가-!!1plt.subplots(figsize=(10,5))f => figureax => axescountplot : 카테고리의 데이터 갯수를 시각화barplot : 막대 그래프jointplot : 두 변수의 관계를 나타내는 그래프 kind에 따라 다름<jupyter_code>f, ax = plt.subplots(figsize=(10, 5))
sns.countplot(x=trn["fecha_dato"], data=trn, alpha=0.5)
plt.show()<jupyter_output><empty_output><jupyter_text>특정 값의 개수를 새고 싶다면..!! trn[col].value_counts()http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.value_counts.html<jupyter_code>trn["fecha_dato"].value_counts()<jupyter_output><empty_output><jupyter_text>숫자가 문자로 되어있는 경우, 공백을 제거하는 테크닉int()로 표현하면 모두 사라짐-!<jupyter_code>aaaaa = "   2   "
int(aaaaa)<jupyter_output><empty_output><jupyter_text>전처리df[col].replace("NA", 0, inplace=True) => NA값을 0으로 바꾼 후,df[col] = df[col]].astype(int) => int화 시킨후 다시 넣기!<jupyter_code>train_data[col].replace(' NA',0,inplace=True)
train_data[col] = train_data[col].astype(int)<jupyter_output><empty_output><jupyter_text>tolist() => list로 나오느냐 array로 나오느냐..!!!<jupyter_code>np.unique(trn["sexo"].astype(str)).tolist()
np.unique(trn["sexo"].astype(str))
label_cols = trn.columns[24:] .tolist()
trn.groupby(['fecha_dato'])[label_cols[i]].agg('sum')
label_cols
# np.asarray

# Convert the input to an array.

# Parameters
# ----------
# a : array_like
#     Input data, in any form that can be converted to an array.  This
#     includes lists, lists of tuples, tuples, tuples of tuples, tuples
#     of lists and ndarrays.
# dtype : data-type, optional
#     By default, the data-type is inferred from the input data.
# order : {'C', 'F'}, optional
#     Whether to use row-major (C-style) or
#     column-major (Fortran-style) memory representation.
#     Defaults to 'C'.

# Returns
# -------
# out : ndarray
#     Array interpretation of `a`.  No copy is performed if the input
#     is already an ndarray.  If `a` is a subclass of ndarray, a base
#     class ndarray is returned.

# See Also
# --------
# asanyarray : Similar function which passes through subclasses.
# ascontiguousarray : Convert input to a contiguous array.
# asfarray : Convert input to a floating point ndarray.
# asfortranarray : Convert input to an ndarray with column-major
#                  memory order.
# asarray_chkfinite : Similar function which checks input for NaNs and Infs.
# fromiter : Create an array from an iterator.
# fromfunction : Construct an array by executing a function on grid
#                positions.

# Examples
# --------
# Convert a list into an array:

# >>> a = [1, 2]
# >>> np.asarray(a)
# array([1, 2])

# Existing arrays are not copied:

# >>> a = np.array([1, 2])
# >>> np.asarray(a) is a
# True

# If `dtype` is set, array is copied only if dtype does not match:

# >>> a = np.array([1, 2], dtype=np.float32)
# >>> np.asarray(a, dtype=np.float32) is a
# True
# >>> np.asarray(a, dtype=np.float64) is a
# False

# Contrary to `asanyarray`, ndarray subclasses are not passed through:

# >>> issubclass(np.matrix, np.ndarray)
# True
# >>> a = np.matrix([[1, 2]])
# >>> np.asarray(a) is a
# False
# >>> np.asanyarray(a) is a
# True<jupyter_output><empty_output><jupyter_text>파이썬 pandas DataFrame의 iloc, loc, ix의 차이.ilocinteger positon를 통해 값을 찾을 수 있다. label로는 찾을 수 없다.loclabel 을 통해 값을 찾을 수 있다. integer position로는 찾을 수 없다..ixinteger position과 label모두 사용 할 수 있다. 만약 label이 숫자라면 label-based index만 된다.http://yeyej.blogspot.kr/2016/02/pandas-dataframe-iloc-loc-ix.html<jupyter_code># data = []
# for ind, (run, row) in enumerate(train.iterrows()):
#     for i in range(24):
#         if row[24+i] == 1:
#             temp = row[:24].values.tolist()
#             temp.append(i)
#             data.append(temp)<jupyter_output><empty_output><jupyter_text>Label encodinglb = LabelEncoder()lb.fit_transform(data)<jupyter_code># lb = LabelEncoder()
# skip_cols = ['fecha_dato','ncodpers','target']
# # histogram of features
# for col in trn.columns:
#     if col in skip_cols:
#         continue
#     print('='*50)
#     print('col : ', col)

#     # check category or number
#     if col in category_cols:
#         x = lb.fit_transform(trn[col])
#         sns.jointplot(x,np.asarray(trn['target'])*1.0, kind="kde")
#     else:
#         x = trn[col]
#         sns.jointplot(x,trn['target'], kind="kde")
#     plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15409599422591122, 'fraction_numerical': 0.0138939011187297, 'mean_word_length': 4.254028436018958, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 74, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '418516', 'license': 'MIT', 'n_tokens_mistral': 2414, 'n_tokens_neox': 2485, 'n_words': 471, 'path': 'notebook/1week_summary.ipynb', 'repo_name': 'zzsza/Kaggle_Santander-Product-Recommendation', 'size': '5542'}