Difference between revisions of "Pandas"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) m Tag: visualeditor |
Rafahsolis (talk | contribs) m Tag: visualeditor |
||
| Line 9: | Line 9: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | == Dataframe == | + | ==Dataframe== |
| − | === Select 1 row === | + | ===Select 1 row=== |
<syntaxhighlight lang="python3"> | <syntaxhighlight lang="python3"> | ||
texts.iloc[[1]] | texts.iloc[[1]] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | === Select 1 column === | + | ===Select 1 column=== |
<syntaxhighlight lang="python3"> | <syntaxhighlight lang="python3"> | ||
sumarys = news[['summary']] | sumarys = news[['summary']] | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | === Select 1 cell === | ||
| + | <syntaxhighlight lang="python3"> | ||
| + | texts.iloc[1][1] | ||
| + | # Or | ||
| + | texts.iloc[1]['summary'] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Python]] | [[Category:Python]] | ||
Revision as of 08:26, 16 May 2019
Install
pip install pandas
Read CSV
news = pd.read_csv('news_2019.05.10.csv')
Dataframe
Select 1 row
texts.iloc[[1]]
Select 1 column
sumarys = news[['summary']]
Select 1 cell
texts.iloc[1][1]
# Or
texts.iloc[1]['summary']