{"flag":true,"single":true,"pageTitle":"Pnadas liberary","post":{"id":289,"user_id":"1","slug":"pnadas-liberary-mrna","title":"Pnadas liberary","body":"<p>Pandas is a Python library used for&nbsp;<strong>analyzing, cleaning, exploring, and manipulating data.. To install<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>C:\\Users\\Your Name&gt;pip install pandas<\/code><\/pre>\r\n<p><strong>Check version:<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>import pandas as pd\r\nprint(pd.__version__)<\/code><\/pre>\r\n<p>A <strong>Pandas Series<\/strong> is like a column in a table.<\/p>\r\n<pre class=\"language-markup\"><code>import pandas as pd\r\na = [1, 7, 2]\r\nmyvar = pd.Series(a)\r\nprint(myvar)\r\nprint(myvar.iloc[0]) #1<\/code><\/pre>\r\n<pre class=\"language-markup\"><code>import pandas as pd\r\ncalories = {\"day1\": 420, \"day2\": 380, \"day3\": 390} #The keys of the dictionary become the labels.\r\nmyvar = pd.Series(calories)\r\nprint(myvar)<\/code><\/pre>\r\n<p>A Pandas <strong>DataFrame<\/strong> is a 2 dimensional data structure, like a 2 dimensional array, or a table with rows and columns.<\/p>\r\n<pre class=\"language-markup\"><code>import pandas as pd\r\ndata = {\r\n      \"name\": [\"apple\",\"kiwi\", \"Banana\"],\r\n      \"calories\": [420, 380, 390],\r\n      \"duration\": [50, 40, 45],\r\n    }\r\n    df = pd.DataFrame(data) #load data into a DataFrame object:\r\n   df.loc[0,\"'newColumn'\"] =\"Hello\" # add a new column newColumn and set first value to Hello\r\n   df['newColumn'] = None # A new colum added with all None values\r\n\r\n    print(df.loc[0])  #return apple, 420,50\r\n    print(df.loc[[0,1]])  #return only 0,1 row<\/code><\/pre>\r\n<div class=\"w3-example\"><strong>READ CSV:<\/strong><\/div>\r\n<div class=\"w3-example\">Pandas will only return the first 5 rows, and the last 5 rows:<\/div>\r\n<div class=\"w3-example\">\r\n<pre class=\"language-markup\"><code>import pandas as pd\r\ndf = pd.read_csv('data.csv') # Dataframe\r\nprint(df.to_string())  #datafram to entire string\r\n\r\nprint(df.head(10)) # with header return 10 rows\r\nprint(df.tail())  # last 5 rows \r\n<\/code><\/pre>\r\n<p><strong>&nbsp; &nbsp;&gt;&gt;Max Rows Limit<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>print(pd.options.display.max_rows) #60 in mostly systems so if there are more than 60 rows in sheet it will return only first and last 5,5\r\npd.options.display.max_rows = 9999 # to increase default rows limit<\/code><\/pre>\r\n<p><strong>JSON&nbsp;= Python DictionarY<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>df = pd.read_json('data.json')\r\nprint(df.to_string())  #use to_string() to print the entire DataFrame.<\/code><\/pre>\r\n<p>&nbsp;<\/p>\r\n<\/div>","category_id":"5","is_private":"0","created_at":"2025-01-29T00:30:56.000000Z","updated_at":"2025-01-30T02:57:16.000000Z","category":{"id":5,"user_id":"1","name":"Python","slug":"python-6gqr","parent_id":null,"created_at":"2023-03-16T12:36:56.000000Z","updated_at":"2023-03-16T12:36:56.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"Pandas is a Python library used for&nbsp;analyzing, cleaning, exploring, and manipulating data.. To install C:\\Users\\Your Name&gt;pip instal - Pnadas liberary (Updated: January 30, 2025) - Read more about Pnadas liberary at my programming site [SITE]","categories":[]}