What is Pandas? Usage of Pandas and Benefits of Pandas

 What is Pandas:

Pandas is a powerful open-source data manipulation and analysis library for Python. It provides easy-to-use data structures and data analysis tools for handling structured data. Here's a breakdown of its usage and benefits:


Usage of Pandas:


1.      Data Structures:


o   Series:

·      1-dimensional labeled array capable of holding any data type (e.g., integers, strings, floating-point numbers, Python objects).


o   DataFrame:

·      2-dimensional labeled data structure with columns of potentially different types. It's similar to a spreadsheet or SQL table.


2.      Data Manipulation:


o   Loading Data:

·      Pandas can read data from various file formats such as CSV, Excel, JSON, SQL databases, and more.


o   Data Cleaning:

·      Handling missing data (NaN values), filtering rows/columns, filling missing values (fillna()), dropping duplicates (drop_duplicates()), etc.


o   Data Transformation:

·       Applying functions to data (apply()), transforming data (transform()), merging and joining datasets (merge()join()), reshaping data (pivot_table()melt()).


o   Indexing and Selection:

·      Selecting subsets of data using labels (loc[]) or integer-based indexing (iloc[]).


3.      Data Analysis:


o   Descriptive Statistics:

·      Calculating summary statistics (mean, median, min, max, etc.) using methods like describe().


o   GroupBy Operations:

·      Splitting data into groups based on some criteria (groupby()), applying a function to each group, and combining the results.


o   Time Series Analysis:

·      Handling time series data efficiently with built-in functionalities for date/time manipulation (resample()rolling()).


4.      Visualization:


o   Integration with Matplotlib and Seaborn libraries for plotting data directly from Pandas objects (plot() method).


Benefits of Pandas:

  • Ease of Use: 
    • Pandas simplifies data manipulation tasks with a high-level API, making it accessible to users with varying levels of programming experience.
  • Performance: 
    • Optimized performance for manipulating and analyzing large datasets, leveraging fast and efficient algorithms implemented in Cython and C.
  • Flexibility: 
    • Supports a wide range of operations on structured data, from simple data cleaning to complex data transformations and statistical analysis.
  • Integration: 
    • Seamless integration with other libraries in the Python ecosystem, such as NumPy, Matplotlib, Scikit-Learn, and more, allowing for comprehensive data analysis workflows.
  • Community Support: 
    • Being open-source, Pandas has a large and active community of users and developers, providing support, tutorials, and extensions (e.g., pandas-profiling, pandasql) that enhance its functionality.

Overall, Pandas is widely used in data analysis, data science, and machine learning projects due to its versatility, efficiency, and ease of use in handling structured data.


Happy Learning!

What is RestAPI and best practices

REST API (Representational State Transfer Application Programming Interface) is a type of web service that follows the principles of REST architectural style. It allows different software applications to communicate with each other over the internet using standard HTTP methods such as GET, POST, PUT, DELETE, etc., and exchanging representations of resources (typically JSON or XML format).

Best Practices for REST APIs:


1.      Use Nouns for Resources:

o   Design URIs that represent resources (nouns) rather than actions (verbs). For example, /users should represent a collection of users.


2.      Use HTTP Methods Correctly:

o   GET should be used for retrieving resources.

o   POST should be used for creating resources.

o   PUT or PATCH for updating resources.

o   DELETE for deleting resources.


3.      Use HTTP Status Codes: Return appropriate status codes with each response:

o   200 OK for successful GETPUT, or DELETE.

o   201 Created for successful POST.

o   400 Bad Request for malformed requests.

o   404 Not Found for resources that do not exist.

o   500 Internal Server Error for server-side errors.


4.      Versioning:

o   Include versioning in your API URIs to manage changes over time (/v1/resource).


5.      Use Plural Nouns for Collections:

o   Use plural nouns for URIs that represent collections (e.g., /users).


6.      Filtering, Sorting, Pagination:

o   Provide mechanisms for filtering, sorting, and pagination of large data sets.


7.      Error Handling:

o   Use consistent error handling throughout the API. Provide informative error messages with details on how to resolve issues.


8.      Security:

o   Implement proper authentication (OAuth, JWT) and authorization mechanisms to secure your API endpoints. Use HTTPS to protect data in transit.


9.      Documentation:

o   Provide clear and comprehensive documentation including endpoint URLs, request/response formats, parameters, and examples.


10.  Use HATEOAS (Hypermedia as the Engine of Application State):

o    Optionally, include links in your API responses to allow clients to discover related resources dynamically.


11.  Optimize Performance:

o   Consider techniques like caching (using HTTP caching headers), gzip compression, and efficient database queries to optimize performance.


12. Testing and Monitoring:

o   Thoroughly test your API endpoints using automated testing tools. Implement logging and monitoring to track API usage and performance.


By following these main best practices, you can create a well-designed and efficient REST API that is easy to use, understand, and maintain.


Happy Learning!

Simple FastAPI application

To get started with a FastAPI application, follow these steps:

1. Install FastAPI

First, make sure you have Python 3.6 or higher installed. Then, install FastAPI using pip:


pip install fastapi

 

2. Create a FastAPI App: 

Create a new Python file (e.g., main.py) and import FastAPI:


from fastapi import FastAPI

app = FastAPI()

 

3. Define a Route: Add a route to your app using a path operation decorator (e.g., @app.get("/")):


@app.get("/")

async def root():

    return {"message": "Hello World"}

 

4. Run the Development Server: Start the live server using the following command:


fastapi dev main.py

 

Access Your App:

Open your browser at http://127.0.0.1:8000 to see the JSON response: {"message": "Hello World"}.

 

Interactive API Docs:

Explore the automatic interactive API documentation at http://127.0.0.1:8000/docs (provided by Swagger UI).

 

Alternative API Docs:

Check out the alternative documentation at http://127.0.0.1:8000/redoc (provided by ReDoc).

 

OpenAPI Schema:

If you’re curious about the raw OpenAPI schema, view it directly at http://127.0.0.1:8000/openapi.json .

 

Happy coding!

How to create flask web application

How to create flask web application:

 

Creating a Flask web application is a straightforward process. Here are the basic steps to get you started:

 

1. Install Flask: First, make sure you have Python installed on your system. Then, install Flask using pip:

pip install flask

 

2. Create a Flask App: Create a new Python file (e.g., app.py) and import Flask:

from flask import Flask

app = Flask(__name__)

 

 3.  Define Routes: Use decorators to define routes for your app.

For example:

@app.route('/')

def home():

    return 'Hello, Flask!'

 

4. Run the App: In your terminal or command prompt, navigate to your project folder and run:

flask run

 

This will start your Flask app, and you can access it in your browser at http://localhost:5000.

Computer shortcuts for faster users

=
Hello guys!!!!

Day by day technologies are becoming more powerful and faster than faster. We are also becoming more faster by using computers, laptops and handheld devices. Now a days we became more smarter so we want to more time saver and light weight devices and for that we are using wearable devices which is more light and smarter.

Lots of people are using Computers and Laptop  but they are unaware about computer shortcuts. By using shortcuts we can save our time and do the more tasks. This post will be  helpful for beginners. Here we are given computer shortcuts for different software and task.


Keyboard Shortcuts and Mouse shortcuts are most of related to Microsoft Windows operating systems.

These are very basic and regularly used Keyboard Shorcuts.
1. CTRL+C (Copy)
2. CTRL+X (Cut)
3. CTRL+V (Paste)
4. CTRL+Z (Undo)
5. DELETE (Delete)
6. SHIFT+DELETE (Delete the selected item permanently without placing the item in the Recycle Bin)
7. CTRL while dragging an item (Copy the selected item)
8. CTRL+SHIFT while dragging an item (Create a shortcut to the selected item)
9. F2 key (Rename the selected item)
10. CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word)
11. CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word)
12. CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph)
13. CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph)
14. CTRL+SHIFT with any of the arrow keys (Highlight a block of text) SHIFT with any of the arrow keys (Select more than one item in a window or on the desktop, or select text in a document)
15. CTRL+A (Select all)
16. F3 key (Search for a file or a folder)
17. ALT+ENTER (View the properties for the selected item)
18. ALT+F4 (Close the active item, or quit the active program)
19. ALT+ENTER (Display the properties of the selected object)
20. ALT+SPACEBAR (Open the shortcut menu for the active window)
21. CTRL+F4 (Close the active document in programs that enable you to have multiple documents opensimultaneou sly)
22. ALT+TAB (Switch between the open items)
23. ALT+ESC (Cycle through items in the order that they had been opened) 24. F6 key (Cycle through the screen elements in a window or on the desktop)
25. F4 key (Display the Address bar list in My Computer or Windows Explorer)
26. SHIFT+F10 (Display the shortcut menu for the selected item)
27. ALT+SPACEBAR (Display the System menu for the active window) 28. CTRL+ESC (Display the Start menu)
29. ALT+Underlined letter in a menu name (Display the corresponding menu) Underlined letter in a command name on an open menu (Perform the corresponding command)
30. F10 key (Activate the menu bar in the active program)
31. RIGHT ARROW (Open the next menu to the right, or open a submenu)
32. LEFT ARROW (Open the next menu to the left, or close a submenu)
33. F5 key (Update the active window)
34. BACKSPACE (View the folder onelevel up in My Computer or Windows Explorer)
35. ESC (Cancel the current task)
36. SHIFT when you insert a CD-ROM into the CD-ROM drive (Prevent the CD-ROM from automatically playing)



Dialog Box - Keyboard Shortcuts 
1. CTRL+TAB (Move forward through the tabs)
2. CTRL+SHIFT+TAB (Move backward through the tabs)
3. TAB (Move forward through the options)
4. SHIFT+TAB (Move backward through the options)
5. ALT+Underlined letter (Perform the corresponding command or select the corresponding option)
6. ENTER (Perform the command for the active option or button)
7. SPACEBAR (Select or clear the check box if the active option is a check box)
8. Arrow keys (Select a button if the active option is a group of option buttons)
9. F1 key (Display Help)
10.F4 key (Display the items in the active list)
11.BACKSPACE (Open a folder one level up if a folder is selected in the Save As or Open dialog box)
Microsoft Natural Keyboard l Shortcuts
1. Windows Logo (Display or hide the Start menu)
2. Windows Logo+BREAK (Display the System Properties dialog box)
3. Windows Logo+D (Display the desktop)
4. Windows Logo+M (Minimize all of the windows)
5. Windows Logo+SHIFT+M (Restorethe minimized windows)
6. Windows Logo+E (Open My Computer)
7. Windows Logo+F (Search for a file or a folder)
8. CTRL+Windows Logo+F (Search for computers)
9. Windows Logo+F1 (Display Windows Help)
10. Windows Logo+ L (Lock the keyboard)
11. Windows Logo+R (Open the Run dialog box)
12. Windows Logo+U (Open Utility Manager)


Accessibility Keyboard Shortcuts
1. Right SHIFT for eight seconds (Switch FilterKeys either on or off)
2. Left ALT+left SHIFT+PRINT SCREEN (Switch High Contrast either on or off)
3. Left ALT+left SHIFT+NUM LOCK (Switch the MouseKeys either on or off)
4. SHIFT five times (Switch the StickyKeys either on or off)
5. NUM LOCK for five seconds (Switch the ToggleKeys either on or off)
6. Windows Logo +U (Open Utility Manager)
7. Windows Explorer Keyboard Shortcuts
8. END (Display the bottom of the active window)
9. HOME (Display the top of the active window)
10. NUM LOCK+Asterisk sign (*) (Display all of the subfolders that are under the selected folder)
11. NUM LOCK+Plus sign (+) (Display the contents of the selected folder)
12. NUM LOCK+Minus sign (-) (Collapse the selected folder)
13. LEFT ARROW (Collapse the current selection if it is expanded, or select the parent folder)
14. RIGHT ARROW (Display the current selection if it is collapsed, or select the first subfolder)


Shortcut Keys for Character Map After you double-click a character on the grid of characters, you can move through the grid by using the keyboard shortcuts:
1. RIGHT ARROW (Move to the rightor to the beginning of the next line)
2. LEFT ARROW (Move to the left orto the end of the previous line) 3. UP ARROW (Move up one row)
4. DOWN ARROW (Move down one row)
5. PAGE UP (Move up one screen at a time)
6. PAGE DOWN (Move down one screen at a time)
7. HOME (Move to the beginning of the line)
8. END (Move to the end of the line)
9. CTRL+HOME (Move to the first character)
10. CTRL+END (Move to the last character)
11. SPACEBAR (Switch between Enlarged and Normal mode when a character is selected)

Microsoft Management Console (MMC) Main Window Keyboard Shortcuts
1. CTRL+O (Open a saved console)
2. CTRL+N (Open a new console)
3. CTRL+S (Save the open console)
4. CTRL+M (Add or remove a console item)
5. CTRL+W (Open a new window)
6. F5 key (Update the content of all console windows)
7. ALT+SPACEBAR (Display the MMC window menu)
8. ALT+F4 (Close the console)
9. ALT+A (Display the Action menu)
10. ALT+V (Display the View menu)
11. ALT+F (Display the File menu)
12. ALT+O (Display the Favorites menu)

MMC Console Window Keyboard Shortcuts
1. CTRL+P (Print the current page or active pane)
2. ALT+Minus sign (-) (Display the window menu for the active console window)
3. SHIFT+F10 (Display the Action shortcut menu for the selected item)
4. F1 key (Open the Help topic, if any, for the selected item)
5. F5 key (Update the content of all console windows)
6. CTRL+F10 (Maximize the active console window)
7. CTRL+F5 (Restore the active console window)
8. ALT+ENTER (Display the Properties dialog box, if any, for theselected item)
9. F2 key (Rename the selected item)
10. CTRL+F4 (Close the active console window. When a console has only one console window, this shortcut closes the console)

Remote Desktop Connection Navigation
1. CTRL+ALT+END (Open the Microsoft Windows NT Security dialog box)
2. ALT+PAGE UP (Switch between programs from left to right)
3. ALT+PAGE DOWN (Switch between programs from right to left) 4. ALT+INSERT (Cycle through the programs in most recently used order)
5. ALT+HOME (Display the Start menu)
6. CTRL+ALT+BREAK (Switch the client computer between a window and a full screen)
7. ALT+DELETE (Display the Windows menu)
8. CTRL+ALT+Minus sign (-) (Place a snapshot of the active window in the client on the Terminal server clipboard and provide the same functionality as pressing PRINT SCREEN on a local computer.)
9. CTRL+ALT+Plus sign (+) (Place asnapshot of the entire client window area on the Terminal server clipboardand provide the same functionality aspressing ALT+PRINT SCREEN on a local computer.)

Microsoft Internet Explorer and other browser Keyboard Shortcuts
1. CTRL+B (Open the Organize Favorites dialog box)
2. CTRL+E (Open the Search bar)
3. CTRL+F (Start the Find utility)
4. CTRL+H (Open the History bar)
5. CTRL+I (Open the Favorites bar)
6. CTRL+L (Open the Open dialog box)
7. CTRL+N (Start another instance of the browser with the same Web address)
8. CTRL+O (Open the Open dialog box,the same as CTRL+L)
9. CTRL+P (Open the Print dialog box)
10. CTRL+R (Update the current Web )

I hope, you may like this so please share it. Share knowledge with your friends. Keep visiting :) :)

Simple Sound Program In C Language



In this post, You can create simple sound programm in C language.

Here, i am using only three function of "dos.h" header.

  • sound() function
  • delay() function
  • nosound() function
1. sound() function
  • sound() function turns the computer speaker on at the specified frequency.
2. delay() function
  • delay() function spends the execution for interval (miliseconds).
 3. nonsound() function 
  • nonsound function turns the computer.

Let's see the simple program of sound() function, delay() function, nosound() function.

#include<dos.h>

void main()
{
        int i;
        while(i==2000)
        {
               sound(i);
               delay(1000);
               i+100;
        }
      nosound();
}

Shutdown computer and laptop by Turbo C


Code for WindowXP
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>

void main()
{   
char shutdown;   
clrscr();   
gotoxy(15,5);
printf("Shutdown your computer now ? (y/n)\n\n\t Answer : ");   
gotoxy(20,7);
scanf("%c",&shutdown);   
if (shutdown == 'y' || shutdown == 'Y')
{
system("C:\\WINDOWS\\System32\\shutdown -s");
}

Code for Ubuntu Linux
#include<stdio.h> 
void main() 
{  
system("shutdown -P now");
}  

Code for Window7

#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main()
{   
char shutdown;   
clrscr();   
gotoxy(15,5);
printf("Shutdown your computer now ? (y/n)\n\n\t Answer : ");   
gotoxy(20,7);
scanf("%c",&shutdown);   
if (shutdown == 'y' || shutdown == 'Y')      
{
system("C:\\WINDOWS\\System32\\shutdown \s");
}

Save program with '.c' extension.
for example shutdown.c

ALT +  F9  through COMPILE program.


CTRL + F9   through RUN program.
  

Thank you for read post.

Captcha in C Language


Captcha in C Language (Turbo c )




If you have window xp then set this path "c:\\tc\\bgi".
For example  initgraph(&amp;getdevice,&amp;getmode,"c:\\tc\\bgi"); 
Write down  code for Captcha

#include<graphics.h>
#include<stdlib.h>

main()
{
   int i = 0, key, num, hx, getdevice = DETECT, getmode,color,maxx,maxy;
   char c[10];


   initgraph(&amp;getdevice,&amp;getmode,"c:\\turboc3\\bgi");


   setcolor(15);
   maxx=getmaxx();
   maxy=getmaxy();
   bar(0,0,maxx,maxy);
    hx = maxx/2;
    setcolor(0);
   settextstyle(1,0,1);
   outtextxy(hx,125,"");
   outtextxy(hx-50,180,"CAPTCHA");
   outtextxy(hx-100,150,"Press escape key to exit...");
   settextstyle(5,0,5);
   settextjustify(1,2);
   setviewport(100,200,600,400,1);
   setcolor(color);

   while(1)
   {
      while(i
&lt; 6)
    {
     num = random(3);

     if ( num == 0 )
        c[i] = 65 + random(26);     /* ASCII value of 65 to 90 is  A  to Z */
     else if ( num == 1)
        c[i] = 97 + random(26);     /* ASCII value of 97 to 122 is  a  to z */
     else
        c[i] = 48 + random(10);     /* ASCII value of 48 to 57 is 0 to 9 */
     i++;
      }
      c[i] = '\0';
      color=random(getmaxcolor());
      setcolor(color);
      outtextxy(210,100,c);

      key = getch();

      if( key == 27 )                     /* ASCII value of 27 is  escape key*/
     exit(0);
      clearviewport();
      i = 0;
   }
}

  
Save programm with '.c' extension.
for example captcha.c

ALT +  F9  through COMPILE program.


CTRL + F9   through RUN program.


Now see  Captacha in C language.
  
Thank you for read my post.

Moving your name on screen in Computer Graphics


If you have WindowXP  then set this path  "c:\\tc\\bgi".
  
Why this path we are set?
 because we set BGI  file ,that is graphical file.
In short we are just set the path of "BGI" folder 

Write down given below code.
 
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>

void main() 
{
    int getdevice=DETECT,getmode,i=1,c,x,y;
   initgraph(&amp;getdevice,&amp;getmode,"c:\\turboc3\\bgi"); 
    while(i)
    {
        if(kbhit())
        {
              break;
        }
        x=random(getmaxx());
        y=random(getmaxy());
        c=random(getmaxcolor());
        settextstyle(4,0,5);
        cleardevice();
        setcolor(c);
        outtextxy(x,y,"Hitesh Rupchandani");
        delay(1000);
    }

    getch();
    closegraph();
}

Here my name Hitesh Rupchandani so you can add your name.
after save program with '.c' extension.
for example myname.c

ALT +  F9  through COMPILE program.


CTRL + F9   through RUN program.


Now see the moving your name in screen

Find your .exe file of this program and other program

Go in My Computer .

In search box  'programname.exe'

for example myname.exe 



If you have any error or query ,you will ask me.

Thank you for read my post .