inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

공공데이터로 파이썬 데이터 분석 시작하기

소스코드와 데이터 다운로드 위치

.뒤에 명령을 실행할 때 () 유무 차이

240

이민형

작성한 질문수 18

1

df_last 같은 변수 뒤에 .을 붙이고 copy() 같은 명령을 실행할 때 ()를 붙이는 기준이 따로 있나요?

copy같은 경우는 ()를 붙일때와 안 붙일때 나오는 값의 형태가 다른 거 같은데 어떤 차이가 있는 건가요?

numpy pandas python

답변 1

1

박조은

안녕하세요.

좋은질문을 해주셨네요. 

소괄호가 붙고 안 붙고의 차이는 Attributes 와 Methods 의 차이입니다.

아래 판다스 DataFrame의 Attributes 와 Methods 목록을 가져왔는데요.

가장 큰 차이는 옵션이 있는지 없는지에 대한 차이가 될거 같아요.

예를 들어 shape는 반환값이 (행, 열) 튜플로 반환이 되는데 이건 옵션이 따로 있지 않아요.

head()는 메소드인데 n 값에 대한 옵션이 있어요.

아래는 DataFrame 의 API 목록인데 Series 를 사용하더라도 같은 방법으로 대부분 사용하실 수 있습니다.

아래 링크를 참고해 보세요.

[pandas.DataFrame — pandas 1.0.3 documentation](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)

Attributes

T

Transpose index and columns.

at

Access a single value for a row/column label pair.

attrs

Dictionary of global attributes on this object.

axes

Return a list representing the axes of the DataFrame.

columns

The column labels of the DataFrame.

dtypes

Return the dtypes in the DataFrame.

empty

Indicator whether DataFrame is empty.

iat

Access a single value for a row/column pair by integer position.

iloc

Purely integer-location based indexing for selection by position.

index

The index (row labels) of the DataFrame.

loc

Access a group of rows and columns by label(s) or a boolean array.

ndim

Return an int representing the number of axes / array dimensions.

shape

Return a tuple representing the dimensionality of the DataFrame.

size

Return an int representing the number of elements in this object.

style

Returns a Styler object.

values

Return a Numpy representation of the DataFrame.

Methods

abs(self)

Return a Series/DataFrame with absolute numeric value of each element.

add(self, other[, axis, level, fill_value])

Get Addition of dataframe and other, element-wise (binary operator add).

add_prefix(self, prefix)

Prefix labels with string prefix.

add_suffix(self, suffix)

Suffix labels with string suffix.

agg(self, func[, axis])

Aggregate using one or more operations over the specified axis.

aggregate(self, func[, axis])

Aggregate using one or more operations over the specified axis.

align(self, other[, join, axis, level, …])

Align two objects on their axes with the specified join method.

all(self[, axis, bool_only, skipna, level])

Return whether all elements are True, potentially over an axis.

any(self[, axis, bool_only, skipna, level])

Return whether any element is True, potentially over an axis.

append(self, other[, ignore_index, …])

Append rows of other to the end of caller, returning a new object.

apply(self, func[, axis, raw, result_type, args])

Apply a function along an axis of the DataFrame.

applymap(self, func)

Apply a function to a Dataframe elementwise.

asfreq(self, freq[, method, fill_value])

Convert TimeSeries to specified frequency.

asof(self, where[, subset])

Return the last row(s) without any NaNs before where.

assign(self, \*\*kwargs)

Assign new columns to a DataFrame.

astype(self, dtype, copy, errors)

Cast a pandas object to a specified dtype dtype.

at_time(self, time, asof[, axis])

Select values at particular time of day (e.g.

between_time(self, start_time, end_time, …)

Select values between particular times of the day (e.g., 9:00-9:30 AM).

bfill(self[, axis, limit, downcast])

Synonym for DataFrame.fillna() with method='bfill'.

bool(self)

Return the bool of a single element PandasObject.

boxplot(self[, column, by, ax, fontsize, …])

Make a box plot from DataFrame columns.

clip(self[, lower, upper, axis])

Trim values at input threshold(s).

combine(self, other, func[, fill_value, …])

Perform column-wise combine with another DataFrame.

combine_first(self, other)

Update null elements with value in the same location in other.

convert_dtypes(self, infer_objects, …)

Convert columns to best possible dtypes using dtypes supporting pd.NA.

copy(self, deep)

Make a copy of this object’s indices and data.

corr(self[, method, min_periods])

Compute pairwise correlation of columns, excluding NA/null values.

corrwith(self, other[, axis, drop, method])

Compute pairwise correlation.

count(self[, axis, level, numeric_only])

Count non-NA cells for each column or row.

cov(self[, min_periods])

Compute pairwise covariance of columns, excluding NA/null values.

cummax(self[, axis, skipna])

Return cumulative maximum over a DataFrame or Series axis.

cummin(self[, axis, skipna])

Return cumulative minimum over a DataFrame or Series axis.

cumprod(self[, axis, skipna])

Return cumulative product over a DataFrame or Series axis.

cumsum(self[, axis, skipna])

Return cumulative sum over a DataFrame or Series axis.

describe(self[, percentiles, include, exclude])

Generate descriptive statistics.

diff(self[, periods, axis])

First discrete difference of element.

div(self, other[, axis, level, fill_value])

Get Floating division of dataframe and other, element-wise (binary operator truediv).

divide(self, other[, axis, level, fill_value])

Get Floating division of dataframe and other, element-wise (binary operator truediv).

dot(self, other)

Compute the matrix multiplication between the DataFrame and other.

drop(self[, labels, axis, index, columns, …])

Drop specified labels from rows or columns.

drop_duplicates(self, subset, …)

Return DataFrame with duplicate rows removed.

droplevel(self, level[, axis])

Return DataFrame with requested index / column level(s) removed.

dropna(self[, axis, how, thresh, subset, …])

Remove missing values.

duplicated(self, subset, Sequence[Hashable], …)

Return boolean Series denoting duplicate rows.

eq(self, other[, axis, level])

Get Equal to of dataframe and other, element-wise (binary operator eq).

equals(self, other)

Test whether two objects contain the same elements.

eval(self, expr[, inplace])

Evaluate a string describing operations on DataFrame columns.

ewm(self[, com, span, halflife, alpha, …])

Provide exponential weighted functions.

패키지 설치 에러 ydata-profiling

0

121

2

자세한 설명 부탁드려요 ㅜ

0

177

2

seaborn 라이브러리 호출하였으나 그래프가 안 그려져요

0

288

2

value_counts와 count 차이

0

343

2

안녕하세요 데이터 최신과 관련해서 문의드립니다.

0

205

3

scatterplot질문

0

122

1

강의 화면이 안나옵니다

0

164

2

4분12초 2013년부터 데이터가 없으면 어떻게하나요?..

0

188

2

에러 메시지

1

303

2

그래프 색이 동일하게 나옵니다.

0

309

2

시각화 라이브러리 비교

0

384

2

주피터 노트북 설치

0

390

1

2. 상가 기술통계 아웃풋 자료에서 오류가 납니다

0

226

1

14. distplot g = sns.FacetGrid(df_last, row="지역명", height=1.7, aspect=4) g.map(sns.distplot, "평당분양가격", hist=False, rug=True); 오류

0

178

1

group by agg function failed 에러

0

687

2

빈도수가 1000개 이상인 데이터를 따로 담을 때 코드 질문 있습니다.

0

288

2

주피터 노트북 실행 했는데 앞에 *가 생기고 결과가 나오지 않아요

0

363

3

get_string함수에서 문자 'nan'

0

200

1

seaborn X축 시작 지점 조정 질의의 건

0

213

1

14강 distplot 질의

0

289

1

nbextension 설치 및 셋팅 후 적용이 안되는 이슈

0

478

1

corr = df.corr() 입력시 오류

1

373

1

keyword grid_b is not recognized

0

336

1

%ls data 매직커맨드 사용시 한글 깨짐

0

293

1