Some basic experiments with the pandas' append command

Understanding Commands: pandas.append() Basic Usage >>> import pandas as pd >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'), index=['x', 'y']) >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'), index=['x', 'y']) >>> df.append(df2) A B x 1 2 y 3 4 x 5 6 y 7 8 >>> df A B x 1 2 y 3 4 >>> new = df.append(df2) >>> new A B x 1 2 y 3 4 x 5 6 y 7 8 >>> df A B x 1 2 y 3 4 >>> df2 A B x 5 6 y 7 8 >>> new....

December 24, 2021 · 2 min · Harsh Kumar

Today I Learnt 10

Lambda Functions in Python First I looked at the following article from realpython.com History Lambda calculus (or $\lambda$-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution.1 It is a universal model of computation. Alternative to a Turing Machine. Until the 1960s, the lambda calculus was only a formalism. Since Richard Montague and other linguists’ applied it in understanding the semantics of natural language, the lambda calculus has gained popularity in both linguistics, and computer science....

April 16, 2021 · 3 min · Harsh Kumar

What are Strings in Python

It’s a Sequence, a Sequence of Characters Can access the characters using the braket operator >>> fruit = 'banana' >>> letter = fruit[1] >>> print(letter) a You get that fruit[1] is a, the second letter in the string. Remeber counting starts from 0 in Python. the number inside the bracket is called the index. Indeces can be negative. But index $\in [-length+1, length -1]$. len is the built-in function which gives the length of a string....

March 7, 2021 · 4 min · Harsh Kumar

How to Iterate in Python

The while loop It allows you to repeat a set of actions until a statement is true. Eg: n = 5 while n > 0: print(n) n = n - 1 print('Blastoff!') This is executed as follows Creates and sets n to 5. Goes to the while statement and checks if n is greater than 0. Right now it’s true, so we move inside the loop. Prints n, ie outputs 5....

March 4, 2021 · 3 min · Harsh Kumar

Learning Python: Functions

What is a Function A function takes a set of inputs and produces an output. Eg: >>>type(32) <class 'init'> Here type is a function that takes 32 as an input and produces its class. Some Built-in functions max : gives the “largest character” in the string >>>max('Hello world') 'w' min : gives the “smallest character” in the string >>>min('Hello world') ' ' len : gives the number of characters in the string...

March 3, 2021 · 3 min · Harsh Kumar