From 208d9dfd000f8e9bda4c902e8e57b957c302e891 Mon Sep 17 00:00:00 2001 From: Parth Modi Date: Tue, 25 Feb 2025 22:05:08 +0100 Subject: [PATCH] pandas1 --- BigCountries.py | 7 +++++++ LowFatProduct.py | 4 ++++ PandasDataFrameFromList.py | 6 ++++++ 3 files changed, 17 insertions(+) create mode 100644 BigCountries.py create mode 100644 LowFatProduct.py create mode 100644 PandasDataFrameFromList.py diff --git a/BigCountries.py b/BigCountries.py new file mode 100644 index 0000000..a96406d --- /dev/null +++ b/BigCountries.py @@ -0,0 +1,7 @@ +import pandas as pd + +def big_countries(world: pd.DataFrame) -> pd.DataFrame: + return world.loc[ + (world['area'] >= 3000000) | (world['population'] >= 25000000), + ['name', 'population','area']] + \ No newline at end of file diff --git a/LowFatProduct.py b/LowFatProduct.py new file mode 100644 index 0000000..6d54813 --- /dev/null +++ b/LowFatProduct.py @@ -0,0 +1,4 @@ +import pandas as pd + +def find_products(products: pd.DataFrame) -> pd.DataFrame: + return products.loc[(products['low_fats'] == 'Y') & (products['recyclable'] == 'Y'), ['product_id']] \ No newline at end of file diff --git a/PandasDataFrameFromList.py b/PandasDataFrameFromList.py new file mode 100644 index 0000000..202b808 --- /dev/null +++ b/PandasDataFrameFromList.py @@ -0,0 +1,6 @@ +import pandas as pd +lst = [['Geek', 25], ['is', 30], + ['for', 26], ['GeeksforGeeks', 22]] +df = pd.DataFrame(lst, columns=['Tag', 'number']) +print(df) +