Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Pandas
(edit)
Revision as of 06:54, 21 May 2019
11 bytes removed
,
06:54, 21 May 2019
m
→Info
Line 6:
Line 6:
==Read CSV==
==Read CSV==
<syntaxhighlight lang="python3">
<syntaxhighlight lang="python3">
−
news
= pd.read_csv('news_2019.05.10.csv')
+
df
= pd.read_csv('news_2019.05.10.csv')
</syntaxhighlight>
</syntaxhighlight>
==Dataframe==
==Dataframe==
−
=== Info ===
+
===Info===
<syntaxhighlight lang="python3">
<syntaxhighlight lang="python3">
−
news
.index
+
df
.index
−
news
.columns
+
df
.columns
−
news
.values
+
df
.values
+
df.head()
</syntaxhighlight>
</syntaxhighlight>
===Select 1 row===
===Select 1 row===
<syntaxhighlight lang="python3">
<syntaxhighlight lang="python3">
−
texts
.iloc[[1]]
+
df
.iloc[[1]]
</syntaxhighlight>
</syntaxhighlight>
===Select 1 column===
===Select 1 column===
<syntaxhighlight lang="python3">
<syntaxhighlight lang="python3">
−
sumarys =
news
[['summary']]
+
sumarys =
df
[['summary']]
# Or
# Or
list(df['one'])
list(df['one'])
Line 33:
Line 34:
===Select 1 cell===
===Select 1 cell===
<syntaxhighlight lang="python3">
<syntaxhighlight lang="python3">
−
texts
.iloc[1][1]
+
df
.iloc[1][1]
# Or
# Or
−
texts
.iloc[1]['summary']
+
df
.iloc[1]['summary']
</syntaxhighlight>
</syntaxhighlight>
[[Category:Python]]
[[Category:Python]]
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version