Happy Weekend To You All
Happy Weekend To You All From The DataPandas Team 🙂
Happy Weekend To You All From The DataPandas Team 🙂
In this quick notes, we will have a look at Rank and Sort in Series and DataFrames in Python In [1]:
|
1 2 3 |
import numpy as np import pandas as pd from pandas import Series, DataFrame |
In [3]:
|
1 2 3 |
#make a series ser1 = Series(range(3), index=['C','A','B']) ser1 |
Out[3]:
|
1 2 3 4 |
C 0 A 1 B 2 dtype: int32 |
In [4]:
|
1 2 |
#sort index of series ser1.sort_index() |
Out[4]:
|
1 2 3 4 |
A 1 B 2 C 0 dtype: int32 |
In [5]:
|
1 2 |
#order or sort by values ser1.order() |
|
1 2 |
C:\Users\adaba\Anaconda3\lib\site-packages\ipykernel\__main__.py:2: FutureWarning: order is deprecated, use sort_values(...) from ipykernel import kernelapp as app |
Out[5]:
|
1 2 3 4 |
C 0 A 1 B 2 dtype: int32 |
In [6]:
|
1 |
ser1.sort_values() |
Out[6]:
|
1 2 3 4 |
C 0 A 1 B 2 dtype: int32 |
In [7]:
|
1 |
from numpy.random import randn |
In [8]:
|
1 2 3 |
#make a series by passing in 10 random numbers ser2 = Series(randn(10)) ser2 |
Out[8]:
|
1 2 3 4 5 6 7 8 9 10 11 |
0 -0.201751 1 1.534109 2 0.542825 3 1.421174 4 -0.173771 5 0.002573 6 -0.490208 7 -0.765340 8 -2.546040 9 -0.456699 dtype: float64 |
In [10]:
|
1 2 |
#sort the values ser2.sort_values() |
…
Want more information like this?
Untitled This is a quick script on how to save Python pivot_table in an excel file. Credit to pbpython In [1]:
|
1 2 3 4 |
import sqlalchemy import pyodbc from pandas import DataFrame import pandas as pd |
In [2]:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
df = DataFrame ## connect to SqlServer Database and get information. try: import urllib params = urllib.quote_plus("DRIVER={SQL Server Native Client 11.0};SERVER=.\MSSQLSERVER_ENT;DATABASE=Antrak;Trusted_Connection=yes;") engine = sqlalchemy.create_engine('mssql+pyodbc:///?odbc_connect=%s"' % params) resoverall = engine.execute("SELECT * FROM FlightBookingsMain") df = df(resoverall.fetchall()) df.columns = resoverall.keys() except (RuntimeError, TypeError, NameError): print('Error in Conneccting') print(RuntimeError, TypeError, NameError) finally: print("connected") |
|
1 |
connected |
In [8]:
|
1 |
df.head() |
Out[8]: First Name Last Name Sex Phone Fax Email Address Booking Date Departure Date Arrival Date Address1 … Number of Passengers Total Cost Currency Numeric Code…
Introduction Github is a web version control system which is very useful when you are working on various projects or you want to keep track of changes you make to your project over time. It is a very useful tool as you venture into Data Science and Programming Objective After you have created a…
Adding actions to messages boxes Message Boxes, like most functions, return one of these values and their respective meanings Button Pressed Return Values: OK = $IDOK (1) CANCEL = $IDCANCEL (2) ABORT = $IDABORT (3) RETRY = $IDRETRY (4) IGNORE = $IDIGNORE (5) YES = $IDYES (6) NO = $IDNO (7) CONTINUE ** = $IDCONTINUE (11) TRY…
Sometimes, you might need some packages which do not come with the standard Python libraries and you would want to install them separately. You will notice how frustrating it is when you get stuck because of a package you are missing. Sentdex on Youtube covers that accurately and you can watch him here: …
An experienced DevOps and Cloud Training Company to meet your DevOps and Cloud needs
You can see how this popup was set up in our step-by-step guide: https://wppopupmaker.com/guides/auto-opening-announcement-popups/