<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Pandas
Fast, flexible, and expressive data structures designed to make working with “relational” or “labeled” data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real world data analysis in Python.
pandas is well suited for many different kinds of data
Step1:  Series
Creating a Series by passing a list of values, letting pandas create a default integer index
Step2:  DataFrame
Creating a DataFrame by passing a numpy array, with a datetime index and labeled columns
Step3:  Creating a DataFrame by passing a dict of objects that can be converted to series-like.
Step4:  Panel
items
Step5:  Viewing data
Step6:  See NumPy data
Step7:  Statistic Summary
Step8:  Transposing data
Step9:  Sorting
Step10:  Selection
Get a column
Step11:  Get rows
Step12:  Selection by Label
Step13:  Adding data
Step14:  Boolean indexing
Step15:  Stats operations
Step16:  Optimized pandas data access
It is recommended to use the optimized pandas data access methods .at, .iat, .loc, .iloc and .ix.
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
Explanation: Pandas
Fast, flexible, and expressive data structures designed to make working with “relational” or “labeled” data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real world data analysis in Python.
pandas is well suited for many different kinds of data:
Tabular data with heterogeneously-typed columns, as in an SQL table or Excel spreadsheet
Ordered and unordered (not necessarily fixed-frequency) time series data.
Arbitrary matrix data (homogeneously typed or heterogeneous) with row and column labels
Any other form of observational / statistical data sets. The data actually need not be labeled at all to be placed into a pandas data structure
In this section we will be looking at some of the basics functions that Pandas can perform
Panda data structures
Series - 1D array
DataFrame - 2D array
Panel - 3D array
Data types - dtypes
Types in pandas objects:
- float
- int
- bool
- datetime64[ns] and datetime64[ns, tz] (in >= 0.17.0)
- timedelta[ns]
- category (in >= 0.15.0)
- object
dtypes have item sizes, e.g. int64 and int32
Standard libraries
End of explanation
s = pd.Series([1,3,5,np.nan,6,8])
s
Explanation: Series
Creating a Series by passing a list of values, letting pandas create a default integer index:
End of explanation
dates = pd.date_range('20130101', periods=6)
dates
df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=list('ABCD'))
df
Explanation: DataFrame
Creating a DataFrame by passing a numpy array, with a datetime index and labeled columns:
End of explanation
df2 = pd.DataFrame({ 'A' : 1.,
   'B' : pd.Timestamp('20130102'),
   'C' : pd.Series(1,index=list(range(4)),dtype='float32'),
   'D' : np.array([3] * 4,dtype='int32'),
   'E' : pd.Categorical(["test","train","test","train"]),
   'F' : 'foo' })
df2
df2.dtypes
Explanation: Creating a DataFrame by passing a dict of objects that can be converted to series-like.
End of explanation
wp = pd.Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
   major_axis=pd.date_range('1/1/2000', periods=5),
   minor_axis=['A', 'B', 'C', 'D'])
wp
Explanation: Panel
items: axis 0, each item corresponds to a DataFrame contained inside
major_axis: axis 1, it is the index (rows) of each of the DataFrames
minor_axis: axis 2, it is the columns of each of the DataFrames
End of explanation
df.head()
df.tail(3)
Explanation: Viewing data
End of explanation
df.index
df.columns
df.values
Explanation: See NumPy data
End of explanation
df.describe()
Explanation: Statistic Summary
End of explanation
df.T
Explanation: Transposing data
End of explanation
df.sort_index(axis=1, ascending=False)
Explanation: Sorting
End of explanation
df['A']
Explanation: Selection
Get a column
End of explanation
# By index
df[0:3]
#By Value
df['20130102':'20130104']
Explanation: Get rows
End of explanation
df.loc[dates[0]]
# Limit columns
df.loc[:,['A','B']]
df_stock = pd.DataFrame({'Stocks': ["AAPL","CA","CTXS","FIS","MA"],
                'Values': [126.17,31.85,65.38,64.08,88.72]})
df_stock
Explanation: Selection by Label
End of explanation
df_stock = df_stock.append({"Stocks":"GOOG", "Values":523.53}, ignore_index=True)
df_stock
Explanation: Adding data
End of explanation
df_stock[df_stock["Values"]>65]
Explanation: Boolean indexing
End of explanation
df_stock.mean()
# Per column
df.mean()
# Per row
df.mean(1)
Explanation: Stats operations
End of explanation
big_dates = pd.date_range('20130101', periods=60000)
big_dates
big_df = pd.DataFrame(np.random.randn(60000,4), index=big_dates, columns=list('ABCD'))
big_df
big_df['20200102':'20200104']
big_df.loc['20130102':'20130104']
%timeit big_df['20200102':'20200104']
%timeit big_df.loc['20200102':'20200104']
big_df[30000:30003]
big_df.iloc[30000:30003]
%timeit big_df[30000:30003]
%timeit big_df.iloc[30000:30003]
Explanation: Optimized pandas data access
It is recommended to use the optimized pandas data access methods .at, .iat, .loc, .iloc and .ix.
End of explanation
<END_TASK>