12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- # read data file in R
- df = data.table::fread('/path/to/file.csv')
- # read data file in Python
- df = pd.read_csv('/path/to/file.csv')
- # list column names in R
- names(df)
- colnames(df)
- # list column names in Python
- df.columns
- # list row names in R
- rownames(df)
- # list row names in Python
- df.index
- # list number of columns in R
- ncol(df)
- # list number of rows in R
- nrow(df)
- # list dimensions of dataframe in R
- dim(df)
- # list dimensions of dataframe in Python
- df.shape
- # access a column of a dataframe in Python
- df['colname'].head(4)
- # access a row of a dataframe in Python
- df.loc[3].head(4)
- df.iloc[3].head(4)
- # list first/last n rows of a dataframe in R
- head(df, n)
- tail(df, n)
- # list first/last n rows of a dataframe in Python
- df.head(n)
- df.tail(n)
- # describe dataframe in R
- summary(df)
- # describe dataframe in Python
- df.describe()
- # data types of attributes in Python
- df.info()
- # correlation of attributes in the data
- df.corr(method='pearson')
|