- read_csv
- sep : Separator
- names : List of column names to use.
- header : To use as the column names, and the start of the data. If column names are passed explicitly then the behavior is identical to header=None.
- low_memory : It results mixed type inference, so set False to ensure no mixed type.
columns=['user_id', 'item_id', 'rating', 'timestamp']
df=pd.read_csv('./u.data',sep='\t', names=columns, low_memory=False)
df.head()
>>>
user_id item_id rating timestamp
0 196 242 3 881250949
1 186 302 3 891717742
2 22 377 1 878887116
- unique
Return unique values.
pd.unique(pd.Series([1,3,1,5]))
>>>
array([1, 3, 5])
- to_csv
Write object to a csv file.
1. First way, using colab : download it to my local via colab.
import pandas as pd
from google.colab import files
uploaded = files.upload()
df_100=df[:100]
df_100.to_csv('df_100.csv')
files.download('df_100.csv')
2. Second way
df_result=df.to_csv('df.csv')
'Analyze Data > Python Libraries' 카테고리의 다른 글
pandas-5. json_normalize (0) | 2021.10.25 |
---|---|
mlxtend-TransactionEncoder, association_rules (0) | 2021.06.23 |
numpy-array, arange, reshape, slicing, newaxis, ...(Ellipsis) (0) | 2021.05.25 |
pandas-2. DataFrame (0) | 2021.05.25 |
pandas-1. Series, reindex, isnull, notnull, fillna, drop, dropna, randn, describe, nan, value_counts, map, apply, concat (0) | 2021.03.05 |