# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: '''Python Interactive'''
#     language: python
#     name: eb2d7657-d636-40cf-996c-6c1457ec907c
# ---

import pandas as pd



pd.DataFrame({"name": ["<NAME>", "<NAME>"], "age": [26, 27]})

pd.Series(['<NAME>', '<NAME>', '<NAME>', '<NAME>'])



pd.Series([30, 40, 50], index=['Ankit', 'Rohit', 'Garima'], name='Friends')

pd['name']

pd.name





friend = pd.read_csv('Friend.csv')

friend

friend.shape

friend.head()

friend.head(1)

friend.tail(1)





fruits = pd.DataFrame({'Apples': [30], 'Bananas': [21]})

fruits

# ## 2.
#
# Create a dataframe `fruit_sales` that matches the diagram below:
#
# ![](https://i.imgur.com/CHPn7ZF.png)





fruit_sale = pd.DataFrame({'Apples': [35, 41], 'Bananas': [21, 34]}, index=['2017 Sales', '2018 Sales'])

fruit_sale



# ## 3.
#
# Create a variable `ingredients` with a Series that looks like:
#
# ```
# Flour     4 cups
# Milk       1 cup
# Eggs     2 large
# Spam       1 can
# Name: Dinner, dtype: object
# ```

ingredients = pd.Series(['4 cups', '1 cup', '2 large', '1 can'], index=['Flour', 'Milk', 'Eggs', 'Spam'], name='Dinner')

ingredients



fruit_sale.to_csv('fruit_sale.csv')



fruit_sale.Apples

fruit_sale['Apples']

fruit_sale['Apples'][0]

fruit_sale['Apples'][1]

fruit_sale['Apples'][-1]

fruit_sale.iloc[0]

fruit_sale.iloc[0:1]

fruit_sale.iloc[0:2]

fruit_sale.iloc[1]

fruit_sale.iloc[0:, 1]





fruit_sale.loc['2018 Sales', 'Apples']



friends = pd.DataFrame({'ankit': [26, 27, 28], 'rohit': [31, 32, 33]})

friends

friends.loc[0, 'ankit']

friends.loc[0:2, 'rohit']

friends.iloc[0:2]

friends.iloc[0:2]['ankit']





friends.set_index('Title')

friends.set_index('rohit')

friends.set_index(['ankit', 'rohit'])

friends.ankit == 26

friends.ankit >= 26

friends.ankit > 26



friends.loc[friends.ankit > 26]

friends.loc[friends.ankit > 26, 'rohit']

friends.loc[(friends.ankit > 26) & (friends.ankit % 2 == 0)]

friends.loc[friends.ankit.isin([27, 28])]



















































































StarcoderdataJupyterScriptsDedupFiltered