Frequently Asked Questions for Pandas
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]newlist = []for x in fruits: if "a" in x: newlist.append(x)print(newlist)fruits = ["apple", "banana", "cherry", "kiwi", "mango"]newlist = [x for x in fruits if "a" in x]print(newlist)|
sum()
|
Sums each value of an object
|
|
count()
|
Returns total Count
|
|
median()
|
Returns mathematical median
|
|
quantile([0.25, 0.75])
|
Quantiles of an object
|
|
min()
|
Lowest value in an object
|
|
max()
|
Highest Value in an Object
|
|
mean()
|
Returns mathematical mean
|
|
var()
|
Returns mathematical variance
|
|
std()
|
Returns standard deviation
|
|
df.groupby(by="col")
|
Groups data by value of specified column (Similar to SQL))
|
|
pd.merge(adf, bdf, how='left', on'col')
|
Merges to Datasheets into one based on a common column
|
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})>>> df.shape(2, 2)DataFrame.mean(axis=None, skipna=None, level=None, numeric_only=None)DataFrame.median(axis=None, skipna=None, level=None, numeric_only=None)# Import pandas library
import pandas as pd
# initialize list of lists
data = [['tom', 10], ['nick', 15], ['juli', 14]]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns = ['Name', 'Age'])
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.