카테고리 없음 2022. 10. 25. 07:39
df = pd.DataFrame([[1,'a'],[2,'b']],columns=['value','name'])
df.set_index('name')['value'].to_dict()
# {'a': 1, 'b': 2}
posted by 초코렛과자
:
Python 2022. 8. 18. 10:32
import pandas as pd
pd.options.display.max_columns = 300

 

'Python' 카테고리의 다른 글

[python] list value rank  (0) 2022.09.08
[python] 포아송 분포  (0) 2022.08.24
dataframe split date  (0) 2022.06.24
dataframe value counts to dataframe  (0) 2022.06.22
loc을 이용한 data 변경  (0) 2022.06.07
posted by 초코렛과자
:
Python 2022. 6. 24. 08:35
import pandas as pd
df = pd.read_csv("data.csv")
pd.to_datetime(df['date+col']).dt.date
pd.to_datetime(df['date+col']).dt.month
pd.to_datetime(df['date+col']).dt.hour

'Python' 카테고리의 다른 글

[python] 포아송 분포  (0) 2022.08.24
pandas dataframe show max columns  (0) 2022.08.18
dataframe value counts to dataframe  (0) 2022.06.22
loc을 이용한 data 변경  (0) 2022.06.07
Isolation Forest와 One-Class SVM  (0) 2022.06.03
posted by 초코렛과자
:
Python 2022. 6. 22. 13:35
df[['col1','col2']].value_counts().rename_axis(['col1','col2']).to_frame('counts')

 

'Python' 카테고리의 다른 글

pandas dataframe show max columns  (0) 2022.08.18
dataframe split date  (0) 2022.06.24
loc을 이용한 data 변경  (0) 2022.06.07
Isolation Forest와 One-Class SVM  (0) 2022.06.03
[python] sklearn RandomizedSearchCV  (0) 2022.05.30
posted by 초코렛과자
:
Python 2022. 6. 7. 15:00
df = pd.read_csv("")

df.loc[df['column'] == 'target', 'column'] = 'change_target'

 

'Python' 카테고리의 다른 글

dataframe split date  (0) 2022.06.24
dataframe value counts to dataframe  (0) 2022.06.22
Isolation Forest와 One-Class SVM  (0) 2022.06.03
[python] sklearn RandomizedSearchCV  (0) 2022.05.30
[python] dataframe column index 가져오기  (0) 2022.05.30
posted by 초코렛과자
:
Python 2022. 5. 2. 11:05
def percentile(n):
    def percentile_(x):
        return np.percentile(x, n)
    percentile_.__name__ = 'percentile_%s' % n
    return percentile_
    
column.agg([np.sum, np.mean, np.std, np.median,
                     np.var, np.min, np.max, percentile(50), percentile(95)])
posted by 초코렛과자
:
Python 2021. 6. 24. 10:28
temp_list = [1,2,3]
df[df['대상column'].isin(temp_list)]

dataframe isin 함수 이용해서 

posted by 초코렛과자
:
Python 2021. 6. 18. 13:01
df = pd.read_csv('FILENAME',
        header=0,
        usecols=["Time", "Name"])

usecols parameter 사용

posted by 초코렛과자
:
Python 2021. 6. 7. 11:52
df2 = df[~df.Name.str.contains('단어')]

 

'Python' 카테고리의 다른 글

dataframe isin 함수  (0) 2021.06.24
Dataframe read csv 원하는 column만 가져오기  (0) 2021.06.18
dataframe 범위별 구간 만들기  (0) 2021.06.02
pandas read csv시 thousand 숫자형으로 읽기  (0) 2021.05.24
plotly를 이용한 pca  (0) 2021.05.18
posted by 초코렛과자
:
Python 2021. 6. 2. 17:30
bins = list(range(0, 100, 10))
bins_label = [str(x)+"~"+str(x+10) for x in bins]
df["labels"] = pd.cut(df['value'], bins, right=False, labels=bins_label[:-1])
posted by 초코렛과자
: