From 66792ec0e9242b7c3935a40c9d502cdf7873da30 Mon Sep 17 00:00:00 2001 From: rakesh kumar Date: Sat, 18 Jan 2020 20:06:38 +0530 Subject: [PATCH 1/5] Pandas started --- fileHandling/Bulk_Image_Resizer.py | 2 +- fileHandling/convert.csv | 11 + fileHandling/csv_to_json_converter.py | 26 ++ fileHandling/json_to_csv.py | 19 ++ jsonFile.json | 1 + .../Untitled-checkpoint.ipynb | 6 - .../Untitled1-checkpoint.ipynb | 6 - .../Untitled2-checkpoint.ipynb | 6 - .../.ipynb_checkpoints/hello-checkpoint.ipynb | 32 -- pandas/Untitled.ipynb | 6 - pandas/Untitled1.ipynb | 62 ---- pandas/Untitled2.ipynb | 278 ------------------ pandas/hello.ipynb | 235 --------------- pandas/p1.py | 4 +- series.py | 31 ++ webscraper/youtubeDownloader.py | 6 +- 16 files changed, 92 insertions(+), 639 deletions(-) create mode 100644 fileHandling/convert.csv create mode 100644 fileHandling/csv_to_json_converter.py create mode 100644 fileHandling/json_to_csv.py create mode 100644 jsonFile.json delete mode 100644 pandas/.ipynb_checkpoints/Untitled-checkpoint.ipynb delete mode 100644 pandas/.ipynb_checkpoints/Untitled1-checkpoint.ipynb delete mode 100644 pandas/.ipynb_checkpoints/Untitled2-checkpoint.ipynb delete mode 100644 pandas/.ipynb_checkpoints/hello-checkpoint.ipynb delete mode 100644 pandas/Untitled.ipynb delete mode 100644 pandas/Untitled1.ipynb delete mode 100644 pandas/Untitled2.ipynb delete mode 100644 pandas/hello.ipynb create mode 100644 series.py diff --git a/fileHandling/Bulk_Image_Resizer.py b/fileHandling/Bulk_Image_Resizer.py index 19bbc59..7e46dc0 100644 --- a/fileHandling/Bulk_Image_Resizer.py +++ b/fileHandling/Bulk_Image_Resizer.py @@ -20,7 +20,7 @@ def small(source,target,original): dest = target + '\\' +original with open(original, 'r+b') as f: with Image.open(f) as image: - cover = resizeimage.resize_cover(image, [960, 640], validate=False) + cover = resizeimage.resize_cover(image, [383, 119], validate=False) cover.save(dest, image.format) def deleteFiles(): diff --git a/fileHandling/convert.csv b/fileHandling/convert.csv new file mode 100644 index 0000000..737a0b1 --- /dev/null +++ b/fileHandling/convert.csv @@ -0,0 +1,11 @@ +album, year, US_peak_chart_post +The White Stripes,1999, - +De Stijl,2000, - +White Blood Cells,20.01,61 +Elephant,2003,6 +Get Behind Me Satan,2005,3 +Icky Thump,2007,2 +Under Great White Northern Lights,2010,11 +Live in Mississippi,2011, - +Live at the Gold Dollar,2012, - +Nine Miles from the White City,2013, - diff --git a/fileHandling/csv_to_json_converter.py b/fileHandling/csv_to_json_converter.py new file mode 100644 index 0000000..e1231be --- /dev/null +++ b/fileHandling/csv_to_json_converter.py @@ -0,0 +1,26 @@ +import csv +import json +with open(r'C:/Users/rakesh\Desktop/python/fileHandling/convert.csv') as csf_file: + csv_reader = csv.reader(csf_file) + line=0 + keys=[] + jon=[] + for row in csv_reader: + d = {} + if line==0: + for col in row: + keys.append(col) + else: + for i in range(len(row)): + d[keys[i]]=row[i] + + if(line>=1): + jon.append(d) + line+=1 +#print(jon) + +with open("jsonFile.json","w") as json_file: + json_file.write( json.dumps(jon,)) + + + diff --git a/fileHandling/json_to_csv.py b/fileHandling/json_to_csv.py new file mode 100644 index 0000000..9a27a00 --- /dev/null +++ b/fileHandling/json_to_csv.py @@ -0,0 +1,19 @@ +# program to convert json file in to csv file +# program by : rakesh kumar +# last edited : 14/01/2020 + +import json +with open(r"C:/Users/rakesh\Desktop/python/jsonFile.json") as json_file: + data = json.load(json_file) + single=0 + header=[] + data=[] + for x in data: + if single==0: + for y in x: + header.append(y) + break; + else: + for z in data: + data.append(z[]) + print(header) \ No newline at end of file diff --git a/jsonFile.json b/jsonFile.json new file mode 100644 index 0000000..9f3257a --- /dev/null +++ b/jsonFile.json @@ -0,0 +1 @@ +[{"album": "The White Stripes", " year": "1999", " US_peak_chart_post": " -"}, {"album": "De Stijl", " year": "2000", " US_peak_chart_post": " -"}, {"album": "White Blood Cells", " year": "20.01", " US_peak_chart_post": "61"}, {"album": "Elephant", " year": "2003", " US_peak_chart_post": "6"}, {"album": "Get Behind Me Satan", " year": "2005", " US_peak_chart_post": "3"}, {"album": "Icky Thump", " year": "2007", " US_peak_chart_post": "2"}, {"album": "Under Great White Northern Lights", " year": "2010", " US_peak_chart_post": "11"}, {"album": "Live in Mississippi", " year": "2011", " US_peak_chart_post": " -"}, {"album": "Live at the Gold Dollar", " year": "2012", " US_peak_chart_post": " -"}, {"album": "Nine Miles from the White City", " year": "2013", " US_peak_chart_post": " -"}] \ No newline at end of file diff --git a/pandas/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/pandas/.ipynb_checkpoints/Untitled-checkpoint.ipynb deleted file mode 100644 index 2fd6442..0000000 --- a/pandas/.ipynb_checkpoints/Untitled-checkpoint.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pandas/.ipynb_checkpoints/Untitled1-checkpoint.ipynb b/pandas/.ipynb_checkpoints/Untitled1-checkpoint.ipynb deleted file mode 100644 index 2fd6442..0000000 --- a/pandas/.ipynb_checkpoints/Untitled1-checkpoint.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pandas/.ipynb_checkpoints/Untitled2-checkpoint.ipynb b/pandas/.ipynb_checkpoints/Untitled2-checkpoint.ipynb deleted file mode 100644 index 2fd6442..0000000 --- a/pandas/.ipynb_checkpoints/Untitled2-checkpoint.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pandas/.ipynb_checkpoints/hello-checkpoint.ipynb b/pandas/.ipynb_checkpoints/hello-checkpoint.ipynb deleted file mode 100644 index 8d151e1..0000000 --- a/pandas/.ipynb_checkpoints/hello-checkpoint.ipynb +++ /dev/null @@ -1,32 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pandas/Untitled.ipynb b/pandas/Untitled.ipynb deleted file mode 100644 index 2fd6442..0000000 --- a/pandas/Untitled.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pandas/Untitled1.ipynb b/pandas/Untitled1.ipynb deleted file mode 100644 index dcdc15b..0000000 --- a/pandas/Untitled1.ipynb +++ /dev/null @@ -1,62 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "ename": "AttributeError", - "evalue": "module 'pandas' has no attribute 'csv_read'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcsv_read\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'vgsales.csv'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;31mAttributeError\u001b[0m: module 'pandas' has no attribute 'csv_read'" - ] - } - ], - "source": [ - "df = pd.csv_read('vgsales.csv')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pandas/Untitled2.ipynb b/pandas/Untitled2.ipynb deleted file mode 100644 index 83520b2..0000000 --- a/pandas/Untitled2.ipynb +++ /dev/null @@ -1,278 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "df = pd.read_csv('E:/python/pandas/vgsales.csv')" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Rank Name Platform \\\n", - "0 1 Wii Sports Wii \n", - "1 2 Super Mario Bros. NES \n", - "2 3 Mario Kart Wii Wii \n", - "3 4 Wii Sports Resort Wii \n", - "4 5 Pokemon Red/Pokemon Blue GB \n", - "5 6 Tetris GB \n", - "6 7 New Super Mario Bros. DS \n", - "7 8 Wii Play Wii \n", - "8 9 New Super Mario Bros. Wii Wii \n", - "9 10 Duck Hunt NES \n", - "10 11 Nintendogs DS \n", - "11 12 Mario Kart DS DS \n", - "12 13 Pokemon Gold/Pokemon Silver GB \n", - "13 14 Wii Fit Wii \n", - "14 15 Wii Fit Plus Wii \n", - "15 16 Kinect Adventures! X360 \n", - "16 17 Grand Theft Auto V PS3 \n", - "17 18 Grand Theft Auto: San Andreas PS2 \n", - "18 19 Super Mario World SNES \n", - "19 20 Brain Age: Train Your Brain in Minutes a Day DS \n", - "20 21 Pokemon Diamond/Pokemon Pearl DS \n", - "21 22 Super Mario Land GB \n", - "22 23 Super Mario Bros. 3 NES \n", - "23 24 Grand Theft Auto V X360 \n", - "24 25 Grand Theft Auto: Vice City PS2 \n", - "25 26 Pokemon Ruby/Pokemon Sapphire GBA \n", - "26 27 Pokemon Black/Pokemon White DS \n", - "27 28 Brain Age 2: More Training in Minutes a Day DS \n", - "28 29 Gran Turismo 3: A-Spec PS2 \n", - "29 30 Call of Duty: Modern Warfare 3 X360 \n", - "... ... ... ... \n", - "16568 16571 XI Coliseum PSP \n", - "16569 16572 Resident Evil 4 HD XOne \n", - "16570 16573 Farming 2017 - The Simulation PS4 \n", - "16571 16574 Grisaia no Kajitsu: La Fruit de la Grisaia PSP \n", - "16572 16575 Scarlett: Nichijou no Kyoukaisen PS2 \n", - "16573 16576 Mini Desktop Racing Wii \n", - "16574 16577 Yattaman Wii: BikkuriDokkiri Machine de Mou Ra... Wii \n", - "16575 16578 Neo Angelique Special PSP \n", - "16576 16579 Rugby Challenge 3 XOne \n", - "16577 16580 Damnation PC \n", - "16578 16581 Outdoors Unleashed: Africa 3D 3DS \n", - "16579 16582 PGA European Tour N64 \n", - "16580 16583 Real Rode PS2 \n", - "16581 16584 Fit & Fun Wii \n", - "16582 16585 Planet Monsters GBA \n", - "16583 16586 Carmageddon 64 N64 \n", - "16584 16587 Bust-A-Move 3000 GC \n", - "16585 16588 Breach PC \n", - "16586 16589 Secret Files 2: Puritas Cordis DS \n", - "16587 16590 Mezase!! Tsuri Master DS DS \n", - "16588 16591 Mega Brain Boost DS \n", - "16589 16592 Chou Ezaru wa Akai Hana: Koi wa Tsuki ni Shiru... PSV \n", - "16590 16593 Eiyuu Densetsu: Sora no Kiseki Material Collec... PSP \n", - "16591 16594 Myst IV: Revelation PC \n", - "16592 16595 Plushees DS \n", - "16593 16596 Woody Woodpecker in Crazy Castle 5 GBA \n", - "16594 16597 Men in Black II: Alien Escape GC \n", - "16595 16598 SCORE International Baja 1000: The Official Game PS2 \n", - "16596 16599 Know How 2 DS \n", - "16597 16600 Spirits & Spells GBA \n", - "\n", - " Year Genre Publisher NA_Sales EU_Sales \\\n", - "0 2006.0 Sports Nintendo 41.49 29.02 \n", - "1 1985.0 Platform Nintendo 29.08 3.58 \n", - "2 2008.0 Racing Nintendo 15.85 12.88 \n", - "3 2009.0 Sports Nintendo 15.75 11.01 \n", - "4 1996.0 Role-Playing Nintendo 11.27 8.89 \n", - "5 1989.0 Puzzle Nintendo 23.20 2.26 \n", - "6 2006.0 Platform Nintendo 11.38 9.23 \n", - "7 2006.0 Misc Nintendo 14.03 9.20 \n", - "8 2009.0 Platform Nintendo 14.59 7.06 \n", - "9 1984.0 Shooter Nintendo 26.93 0.63 \n", - "10 2005.0 Simulation Nintendo 9.07 11.00 \n", - "11 2005.0 Racing Nintendo 9.81 7.57 \n", - "12 1999.0 Role-Playing Nintendo 9.00 6.18 \n", - "13 2007.0 Sports Nintendo 8.94 8.03 \n", - "14 2009.0 Sports Nintendo 9.09 8.59 \n", - "15 2010.0 Misc Microsoft Game Studios 14.97 4.94 \n", - "16 2013.0 Action Take-Two Interactive 7.01 9.27 \n", - "17 2004.0 Action Take-Two Interactive 9.43 0.40 \n", - "18 1990.0 Platform Nintendo 12.78 3.75 \n", - "19 2005.0 Misc Nintendo 4.75 9.26 \n", - "20 2006.0 Role-Playing Nintendo 6.42 4.52 \n", - "21 1989.0 Platform Nintendo 10.83 2.71 \n", - "22 1988.0 Platform Nintendo 9.54 3.44 \n", - "23 2013.0 Action Take-Two Interactive 9.63 5.31 \n", - "24 2002.0 Action Take-Two Interactive 8.41 5.49 \n", - "25 2002.0 Role-Playing Nintendo 6.06 3.90 \n", - "26 2010.0 Role-Playing Nintendo 5.57 3.28 \n", - "27 2005.0 Puzzle Nintendo 3.44 5.36 \n", - "28 2001.0 Racing Sony Computer Entertainment 6.85 5.09 \n", - "29 2011.0 Shooter Activision 9.03 4.28 \n", - "... ... ... ... ... ... \n", - "16568 2006.0 Puzzle Sony Computer Entertainment 0.00 0.00 \n", - "16569 2016.0 Shooter Capcom 0.01 0.00 \n", - "16570 2016.0 Simulation UIG Entertainment 0.00 0.01 \n", - "16571 2013.0 Adventure Prototype 0.00 0.00 \n", - "16572 2008.0 Adventure Kadokawa Shoten 0.00 0.00 \n", - "16573 2007.0 Racing Popcorn Arcade 0.01 0.00 \n", - "16574 2008.0 Racing Takara Tomy 0.00 0.00 \n", - "16575 2008.0 Adventure Tecmo Koei 0.00 0.00 \n", - "16576 2016.0 Sports Alternative Software 0.00 0.01 \n", - "16577 2009.0 Shooter Codemasters 0.00 0.01 \n", - "16578 2011.0 Sports Mastiff 0.01 0.00 \n", - "16579 2000.0 Sports Infogrames 0.01 0.00 \n", - "16580 2008.0 Adventure Kadokawa Shoten 0.00 0.00 \n", - "16581 2011.0 Sports Unknown 0.00 0.01 \n", - "16582 2001.0 Action Titus 0.01 0.00 \n", - "16583 1999.0 Action Virgin Interactive 0.01 0.00 \n", - "16584 2003.0 Puzzle Ubisoft 0.01 0.00 \n", - "16585 2011.0 Shooter Destineer 0.01 0.00 \n", - "16586 2009.0 Adventure Deep Silver 0.00 0.01 \n", - "16587 2009.0 Sports Hudson Soft 0.00 0.00 \n", - "16588 2008.0 Puzzle Majesco Entertainment 0.01 0.00 \n", - "16589 2016.0 Action dramatic create 0.00 0.00 \n", - "16590 2007.0 Role-Playing Falcom Corporation 0.00 0.00 \n", - "16591 2004.0 Adventure Ubisoft 0.01 0.00 \n", - "16592 2008.0 Simulation Destineer 0.01 0.00 \n", - "16593 2002.0 Platform Kemco 0.01 0.00 \n", - "16594 2003.0 Shooter Infogrames 0.01 0.00 \n", - "16595 2008.0 Racing Activision 0.00 0.00 \n", - "16596 2010.0 Puzzle 7G//AMES 0.00 0.01 \n", - "16597 2003.0 Platform Wanadoo 0.01 0.00 \n", - "\n", - " JP_Sales Other_Sales Global_Sales \n", - "0 3.77 8.46 82.74 \n", - "1 6.81 0.77 40.24 \n", - "2 3.79 3.31 35.82 \n", - "3 3.28 2.96 33.00 \n", - "4 10.22 1.00 31.37 \n", - "5 4.22 0.58 30.26 \n", - "6 6.50 2.90 30.01 \n", - "7 2.93 2.85 29.02 \n", - "8 4.70 2.26 28.62 \n", - "9 0.28 0.47 28.31 \n", - "10 1.93 2.75 24.76 \n", - "11 4.13 1.92 23.42 \n", - "12 7.20 0.71 23.10 \n", - "13 3.60 2.15 22.72 \n", - "14 2.53 1.79 22.00 \n", - "15 0.24 1.67 21.82 \n", - "16 0.97 4.14 21.40 \n", - "17 0.41 10.57 20.81 \n", - "18 3.54 0.55 20.61 \n", - "19 4.16 2.05 20.22 \n", - "20 6.04 1.37 18.36 \n", - "21 4.18 0.42 18.14 \n", - "22 3.84 0.46 17.28 \n", - "23 0.06 1.38 16.38 \n", - "24 0.47 1.78 16.15 \n", - "25 5.38 0.50 15.85 \n", - "26 5.65 0.82 15.32 \n", - "27 5.32 1.18 15.30 \n", - "28 1.87 1.16 14.98 \n", - "29 0.13 1.32 14.76 \n", - "... ... ... ... \n", - "16568 0.01 0.00 0.01 \n", - "16569 0.00 0.00 0.01 \n", - "16570 0.00 0.00 0.01 \n", - "16571 0.01 0.00 0.01 \n", - "16572 0.01 0.00 0.01 \n", - "16573 0.00 0.00 0.01 \n", - "16574 0.01 0.00 0.01 \n", - "16575 0.01 0.00 0.01 \n", - "16576 0.00 0.00 0.01 \n", - "16577 0.00 0.00 0.01 \n", - "16578 0.00 0.00 0.01 \n", - "16579 0.00 0.00 0.01 \n", - "16580 0.01 0.00 0.01 \n", - "16581 0.00 0.00 0.01 \n", - "16582 0.00 0.00 0.01 \n", - "16583 0.00 0.00 0.01 \n", - "16584 0.00 0.00 0.01 \n", - "16585 0.00 0.00 0.01 \n", - "16586 0.00 0.00 0.01 \n", - "16587 0.01 0.00 0.01 \n", - "16588 0.00 0.00 0.01 \n", - "16589 0.01 0.00 0.01 \n", - "16590 0.01 0.00 0.01 \n", - "16591 0.00 0.00 0.01 \n", - "16592 0.00 0.00 0.01 \n", - "16593 0.00 0.00 0.01 \n", - "16594 0.00 0.00 0.01 \n", - "16595 0.00 0.00 0.01 \n", - "16596 0.00 0.00 0.01 \n", - "16597 0.00 0.00 0.01 \n", - "\n", - "[16598 rows x 11 columns]\n" - ] - } - ], - "source": [ - "print(df)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "ename": "AttributeError", - "evalue": "'DataFrame' object has no attribute 'header'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mheader\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;32mc:\\python37\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36m__getattr__\u001b[1;34m(self, name)\u001b[0m\n\u001b[0;32m 5065\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_info_axis\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_can_hold_identifiers_and_holds_name\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5066\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 5067\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__getattribute__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 5068\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5069\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m__setattr__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mAttributeError\u001b[0m: 'DataFrame' object has no attribute 'header'" - ] - } - ], - "source": [ - "df.header()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pandas/hello.ipynb b/pandas/hello.ipynb deleted file mode 100644 index 4774e80..0000000 --- a/pandas/hello.ipynb +++ /dev/null @@ -1,235 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(16598, 11)" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "import pandas as pd\n", - "df = pd.read_csv('vgsales.csv')\n", - "df.shape" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.describe()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
RankYearNA_SalesEU_SalesJP_SalesOther_SalesGlobal_Sales
count16598.00000016327.00000016598.00000016598.00000016598.00000016598.00000016598.000000
mean8300.6052542006.4064430.2646670.1466520.0777820.0480630.537441
std4791.8539335.8289810.8166830.5053510.3092910.1885881.555028
min1.0000001980.0000000.0000000.0000000.0000000.0000000.010000
25%4151.2500002003.0000000.0000000.0000000.0000000.0000000.060000
50%8300.5000002007.0000000.0800000.0200000.0000000.0100000.170000
75%12449.7500002010.0000000.2400000.1100000.0400000.0400000.470000
max16600.0000002020.00000041.49000029.02000010.22000010.57000082.740000
\n", - "
" - ], - "text/plain": [ - " Rank Year NA_Sales EU_Sales JP_Sales \\\n", - "count 16598.000000 16327.000000 16598.000000 16598.000000 16598.000000 \n", - "mean 8300.605254 2006.406443 0.264667 0.146652 0.077782 \n", - "std 4791.853933 5.828981 0.816683 0.505351 0.309291 \n", - "min 1.000000 1980.000000 0.000000 0.000000 0.000000 \n", - "25% 4151.250000 2003.000000 0.000000 0.000000 0.000000 \n", - "50% 8300.500000 2007.000000 0.080000 0.020000 0.000000 \n", - "75% 12449.750000 2010.000000 0.240000 0.110000 0.040000 \n", - "max 16600.000000 2020.000000 41.490000 29.020000 10.220000 \n", - "\n", - " Other_Sales Global_Sales \n", - "count 16598.000000 16598.000000 \n", - "mean 0.048063 0.537441 \n", - "std 0.188588 1.555028 \n", - "min 0.000000 0.010000 \n", - "25% 0.000000 0.060000 \n", - "50% 0.010000 0.170000 \n", - "75% 0.040000 0.470000 \n", - "max 10.570000 82.740000 " - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.describe()" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[1, 'Wii Sports', 'Wii', ..., 3.77, 8.46, 82.74],\n", - " [2, 'Super Mario Bros.', 'NES', ..., 6.81, 0.77, 40.24],\n", - " [3, 'Mario Kart Wii', 'Wii', ..., 3.79, 3.31, 35.82],\n", - " ...,\n", - " [16598, 'SCORE International Baja 1000: The Official Game', 'PS2',\n", - " ..., 0.0, 0.0, 0.01],\n", - " [16599, 'Know How 2', 'DS', ..., 0.0, 0.0, 0.01],\n", - " [16600, 'Spirits & Spells', 'GBA', ..., 0.0, 0.0, 0.01]],\n", - " dtype=object)" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.values" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pandas/p1.py b/pandas/p1.py index f8f67a1..a17d5ee 100644 --- a/pandas/p1.py +++ b/pandas/p1.py @@ -1,3 +1,3 @@ import pandas as pd -df = pd.read_csv('E:/python/pandas/vgsales.csv') -print(df) +df = pd.read_csv('C:/Users/rakesh\Desktop/python/pandas/vgsales.csv') +print(df.head(10)) diff --git a/series.py b/series.py new file mode 100644 index 0000000..79a2ab6 --- /dev/null +++ b/series.py @@ -0,0 +1,31 @@ +import pandas as pd + +#blank series +s = pd.Series() +print(s) + +#series with numbers +s = pd.Series([10,20,30,40,50]) +print(s) + +#series with numbers and index + +s= pd.Series([10,20,30,40,50],index=[1,2,3,4,5]) +print(s) + +#series with numbers and char index +s = pd.Series([10,20,30,40,50],index=['a','b','c','d','e']) +print(s) + +#series with constant values +s = pd.Series(55,index=[1,2,3,4,5,6]) +print(s) + +#series with constant and python function +s = pd.Series(34,index= range(100)) +print(s) + +# series with python function +s = pd.Series(range(2,89)) +print(s) + diff --git a/webscraper/youtubeDownloader.py b/webscraper/youtubeDownloader.py index ef6948d..3d81cdc 100644 --- a/webscraper/youtubeDownloader.py +++ b/webscraper/youtubeDownloader.py @@ -5,8 +5,4 @@ ydl_opts = {} with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download( -<<<<<<< HEAD - ['https://www.youtube.com/watch?v=skG_36Abhos']) -======= - ['https://www.youtube.com/watch?v=7nH2NYpeKa4&list=PLuiqR73XWRBZ7PpaADMES1LCtvzkc2MJt&index=1']) ->>>>>>> 1ddf82b2ad35dc035189900c6208296c03e16f97 + ['https://www.youtube.com/watch?v=SCoGwHCNXVw']) From e7988f7ebf25ec216a001f209f025b1249580cac Mon Sep 17 00:00:00 2001 From: rakesh kumar Date: Sat, 18 Jan 2020 20:29:26 +0530 Subject: [PATCH 2/5] pandas series demonstrated --- pandas/series.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ series.py | 40 ++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 pandas/series.py diff --git a/pandas/series.py b/pandas/series.py new file mode 100644 index 0000000..ae00a9b --- /dev/null +++ b/pandas/series.py @@ -0,0 +1,73 @@ +import pandas as pd +import numpy as np + +#blank series +s = pd.Series() +print(s) + +#series with numbers +s = pd.Series([10, 20, 30, 40, 50]) +print(s) + +#series with numbers and index + +s = pd.Series([10, 20, 30, 40, 50], index=[1, 2, 3, 4, 5]) +print(s) + +#series with numbers and char index +s = pd.Series([10, 20, 30, 40, 50], index=['a', 'b', 'c', 'd', 'e']) +print(s) + +#series with constant values +s = pd.Series(55, index=[1, 2, 3, 4, 5, 6]) +print(s) + +#series with constant and python function +s = pd.Series(34, index=range(100)) +print(s) + +# series with python function +s = pd.Series(range(2, 89)) +print(s) + +# series with float values +s = pd.Series([10, 20, 30, 40.5, 50]) +print(s) + +# series with string type values +s = pd.Series('Welcome to DAV Chander Nagar', index=[1, 2, 3, 4, 5, 6]) +print(s) + +# series with string and index also in string + +s = pd.Series('Welcome to DAV Chander Nagar', index=[ + 'rakesh', 'arushi', 'mannat', 'vinay', 'pratham']) +print(s) + +# series with range and for loop +s = pd.Series(range(5), index=[x for x in 'abcde']) +print(s) + +# series with two different lists +names = ['rakesh', 'vishank', 'nikunj', 'unnati', 'vipul'] +city = ['GZB', 'Delhi', 'Meerut', 'Pune', 'Panji'] +s = pd.Series(names, index=city) +print(s) + + +#series with Nan values of numpy + +s = pd.Series([10, 20, 30, np.NaN, -34.5, 6]) +print(s) + +#series from a python Dictionary +dict1 = {'name': 'rakesh', 'roll': 20, 'city': 'Gzb', + 'age': 40, 'profession': 'Teaching'} +s = pd.Series(dict1) +print(s) + + +# series using a mathematical expression +data = np.arange(10, 15) +s = pd.Series(data**2, index=data) +print(s) diff --git a/series.py b/series.py index 79a2ab6..938e6e4 100644 --- a/series.py +++ b/series.py @@ -1,4 +1,5 @@ import pandas as pd +import numpy as np #blank series s = pd.Series() @@ -29,3 +30,42 @@ s = pd.Series(range(2,89)) print(s) +# series with float values +s = pd.Series([10,20,30,40.5,50]) +print(s) + +# series with string type values +s = pd.Series('Welcome to DAV Chander Nagar',index=[1,2,3,4,5,6]) +print(s) + +# series with string and index also in string + +s= pd.Series('Welcome to DAV Chander Nagar',index=['rakesh','arushi','mannat','vinay','pratham']) +print(s) + +# series with range and for loop +s = pd.Series(range(5),index = [x for x in 'abcde']) +print(s) + +# series with two different lists +names =['rakesh','vishank','nikunj','unnati','vipul'] +city = [ 'GZB','Delhi','Meerut','Pune','Panji' ] +s = pd.Series(names,index=city) +print(s) + + +#series with Nan values of numpy + +s = pd.Series([10,20,30,np.NaN,-34.5,6]) +print(s) + +#series from a python Dictionary +dict1={'name':'rakesh','roll':20,'city':'Gzb','age':40,'profession':'Teaching'} +s= pd.Series(dict1) +print(s) + + +# series using a mathematical expression +data =np.arange(10,15) +s= pd.Series(data**2,index= data) +print(s) \ No newline at end of file From a958f43bc7b01b2c8fe67e20f0901d4c68fe881c Mon Sep 17 00:00:00 2001 From: rakesh kumar Date: Sun, 19 Jan 2020 13:19:58 +0530 Subject: [PATCH 3/5] pandas series demonstrated --- pandas/head_tail_series.py | 13 +++++++++++++ pandas/math_operation_series.py | 19 +++++++++++++++++++ pandas/{series.py => series_define.py} | 0 pandas/series_object.py | 25 +++++++++++++++++++++++++ pandas/vector_operation_series.py | 7 +++++++ 5 files changed, 64 insertions(+) create mode 100644 pandas/head_tail_series.py create mode 100644 pandas/math_operation_series.py rename pandas/{series.py => series_define.py} (100%) create mode 100644 pandas/series_object.py create mode 100644 pandas/vector_operation_series.py diff --git a/pandas/head_tail_series.py b/pandas/head_tail_series.py new file mode 100644 index 0000000..f63b123 --- /dev/null +++ b/pandas/head_tail_series.py @@ -0,0 +1,13 @@ +# retirve values from pandas series using head() and tail() function + +import pandas as pd +s= pd.Series(range(1,1000,5)) +#print top 5 entries of the series +print(s.head()) +#print top 2 entries of the series +print(s.head(2)) + +#print last 5 entries of the series +print(s.tail()) +# print last 2 entries of the series +print(s.tail(2)) diff --git a/pandas/math_operation_series.py b/pandas/math_operation_series.py new file mode 100644 index 0000000..efc79df --- /dev/null +++ b/pandas/math_operation_series.py @@ -0,0 +1,19 @@ +# mathematical operation on pandas series + +import pandas as pd +s= pd.Series(range(10)) +s1 = pd.Series(range(20,30)) +print(s) +print(s1) + +s2 = s+s1 +print("s2 = s+s1") +print(s2) + +s2 = s+50 +print("s2= s+50") +print(s2) + +s2 = s*s1 +print("s2= s*s1") +print(s2) \ No newline at end of file diff --git a/pandas/series.py b/pandas/series_define.py similarity index 100% rename from pandas/series.py rename to pandas/series_define.py diff --git a/pandas/series_object.py b/pandas/series_object.py new file mode 100644 index 0000000..61ff187 --- /dev/null +++ b/pandas/series_object.py @@ -0,0 +1,25 @@ +# python pandas series attributes +# series.index - Return index onfthe series +# series.values - return ndarray +# series.dtype - return dtype object of the underlying data +# series.shape - return tuple of the shape of the underlying data +# series.nbytes - return number of bypes of underlying data +# series.ndim - return the number of dimension +# series.size - return the number of elements +# series.hasnans - return true if there are any Nan value +# series.empty - return true if series object is empty + + + +import pandas as pd + +s= pd.Series(range(3,30,3)) +print(s.index) +print(s.values) +print(s.dtype) +print(s.shape) +print(s.nbytes) +print(s.ndim) +print(s.size) +print(s.hasnans) +print(s.empty) \ No newline at end of file diff --git a/pandas/vector_operation_series.py b/pandas/vector_operation_series.py new file mode 100644 index 0000000..8089557 --- /dev/null +++ b/pandas/vector_operation_series.py @@ -0,0 +1,7 @@ +import pandas as pd +s = pd.Series(range(2,40)) +print("Print True if Values Greater than 12 else faslse") +print(s>12) + +print("Print values greater than 12") +print(s[s>12]) \ No newline at end of file From 610a6c83a25ae10268c8e683f72297e0247295ce Mon Sep 17 00:00:00 2001 From: rakesh kumar Date: Sun, 19 Jan 2020 13:38:51 +0530 Subject: [PATCH 4/5] pandas series demonstrated --- .../dataFrames/DataFrame_from_dictionary.py | 0 pandas/dataFrames/generation.py | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 pandas/dataFrames/DataFrame_from_dictionary.py create mode 100644 pandas/dataFrames/generation.py diff --git a/pandas/dataFrames/DataFrame_from_dictionary.py b/pandas/dataFrames/DataFrame_from_dictionary.py new file mode 100644 index 0000000..e69de29 diff --git a/pandas/dataFrames/generation.py b/pandas/dataFrames/generation.py new file mode 100644 index 0000000..0f213a2 --- /dev/null +++ b/pandas/dataFrames/generation.py @@ -0,0 +1,23 @@ +# pandas dataframes generation using different methods + +import pandas as pd +df = pd.DataFrame() +print(df) + +# DataFrame using python list +df = pd.DataFrame([10,20,30,40,50,60]) +print(df) + +# DataFrame using pandas series + +marks = pd.Series({'rakesh':56,'anuj':89,'Bhumi':90,'Jagdev':80}) +age = pd.Series({'rakesh':18,'anuj':18,'Bhumi':16,'Jagdev':19}) +print(marks) +print(age) + +df=pd.DataFrame({'marks':marks,'age':age}) +print(df) + +#sorting DataFrame values using sort_value() +print(df.sort_values(by=['marks'])) +print(df.sort_values(by=['marks'],ascending=False)) \ No newline at end of file From 4862d6baee53c91054712373dd7190e101b83a22 Mon Sep 17 00:00:00 2001 From: rakesh kumar Date: Sun, 19 Jan 2020 13:44:43 +0530 Subject: [PATCH 5/5] pandas series demonstrated --- pandas/dataFrames/DataFrame_from_dictionary.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/dataFrames/DataFrame_from_dictionary.py b/pandas/dataFrames/DataFrame_from_dictionary.py index e69de29..9a169b7 100644 --- a/pandas/dataFrames/DataFrame_from_dictionary.py +++ b/pandas/dataFrames/DataFrame_from_dictionary.py @@ -0,0 +1,9 @@ +# Pandas DataFrame from python dictionary +import pandas as pd + +student ={'name':['rakesh','suresh','disha','arun','gulati','unnati'],'IP':[56,78,56,78,78,67],'English':[67,78,87,67,78,34],'Pol':[55,78,88,56,90,94]} +df= pd.DataFrame(student) +print(df) +print(df[:3]) +print(df.head(3)) +print(df.tail(2)) \ No newline at end of file