pandas

Python Pandas Pivot Table Index location Percentage calculation on Two columns – XlsxWriter pt2
| |

Python Pandas Pivot Table Index location Percentage calculation on Two columns – XlsxWriter pt2

This is a just a bit of addition to a previous post, by formatting the Excel output further using the Python XlsxWriter package. The additions are : Colour formatting has been added to the Total Cost column The “Total Cost” has been given a money formatting The above uses row : column numeric values instead…

|

Save Python Pivot Table in Excel Sheets ExcelWriter

Untitled This is a quick script on how to save Python pivot_table in an excel file. Credit to  pbpython In [1]: import sqlalchemy import pyodbc from pandas import DataFrame import pandas as pd   In [2]: 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;”)…

Python Pandas Pivot Table Index location Percentage calculation on Two columns

pivot table for year on year This is a quick example of how to use pivot_table,  to calculate year on year percentage sales . In [162]: import sqlalchemy import pyodbc import numpy as np from pandas import DataFrame from bokeh.plotting import figure, output_file, show import pandas as pd   In [163]: df = DataFrame ## connect to…

Python Bokeh plotting Data Exploration Visualization And Pivot Tables Analysis

This is a quick walk through Bokeh data exploration and visualization and also python pivot_tables (credit to pbpython on the pivot_tables).Visualization Dashboard In [49]: import sqlalchemy import pyodbc from pandas import DataFrame from bokeh.plotting import figure, output_file, show import pandas as pd   In [50]: df = DataFrame ## connect to SqlServer Database and get information. try: import…

Python Pandas Groupby function agg Series GroupbyObject

Python Pandas Groupby function agg Series GroupbyObject

Group By FunctionThis is a quick look at Python groupby function. Very powerful and useful function. We will take a simple look at it here. Credits to Data School , creator of Python course materials. lets import sample dataset In [18]: import pandas as pd   In [19]: drinks = pd.read_csv(‘http://bit.ly/drinksbycountry’)   In [20]: #lets check the head…

Python iloc, loc, ix Data Retrieving Selection Functions
|

Python iloc, loc, ix Data Retrieving Selection Functions

  Pandas iloc, loc, and ix functions are very powerful ways to quickly select data from your dataframe. Today , we take a quick look at these 3 functions. Credits to Data School, you can check him out in Youtube  In [1]: import pandas as pd   In [2]: #lets get this public dataset and play with it…

Aggregation – Pandas Numpy Python Series DataFrame

  In this quick notes, we will go through aggregation in Python. This is part of lectures on Learning Python for Data Analysis and Visualization by Jose Portilla on Udemy. import numpy as np import pandas as pd from pandas import Series, DataFrame   url = “http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/” In [2]: dframe_wine = pd.read_csv(‘winequality-red.csv’, sep=’;’)   In [4]: dframe_wine.head()   Out[4]: fixed…

|

Rank Sort Series DataFrames in Python Pandas Numpy

  In this quick notes, we will have a look at Rank and Sort in Series and DataFrames in Python In [1]: import numpy as np import pandas as pd from pandas import Series, DataFrame   In [3]: #make a series ser1 = Series(range(3), index=[‘C’,’A’,’B’]) ser1   Out[3]: C 0 A 1 B 2 dtype: int32 In [4]:…

|

Pandas DataFrame and Series Alignment Python Notes

This week we have a look at Data Alignment in Python In [1]: import numpy as np import pandas as pd from pandas import Series, DataFrame   In [2]: #create series ser1 = Series([0,1,3], index=[‘A’,’B’,’C’]) ser1   Out[2]: A 0 B 1 C 3 dtype: int64 In [3]: ser2 = Series([3,4,5,6], index=[‘A’,’B’,’C’,’D’]) ser2   Out[3]: A 3 B…