Difference between revisions of "Pandas"

From RHS Wiki
Jump to navigation Jump to search
Tag: visualeditor
Tag: visualeditor
Line 17: Line 17:
 
df.values
 
df.values
 
df.shape
 
df.shape
 +
df.dtypes
 
df.head()
 
df.head()
 +
df.info()
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 06:56, 21 May 2019

Install

pip install pandas

Read CSV

df = pd.read_csv('news_2019.05.10.csv')

Dataframe

Info

df.index
df.columns
df.values
df.shape
df.dtypes
df.head()
df.info()

Select 1 row

df.iloc[[1]]

Select 1 column

sumarys = df[['summary']]
# Or
list(df['one'])
dfToList = df['one'].tolist()

Select 1 cell

df.iloc[1][1]
# Or
df.iloc[1]['summary']