Tuesday, 26 April 2022

Append Tables' Rows

 How to add rows from another table to existing dataframe? 

import pandas as pd

df1 = pd.DataFrame({"x": [5, 2], "y": [4, 7], "z": [9, 3]})
df2 = pd.DataFrame({"x": [1, 3], "y": [1, 9], "z": [29, 30]})

print "Input DataFrame 1 is:\n", df1
print "Input DataFrame 2 is:\n", df2

df3 = df1.append(df2, ignore_index=True)

print "After appending, DataFrame is: \n", df3

 

Tuesday, 22 June 2021

Renaming pandas column without knowing column name.

#rename unknown pandas column. #rename columns I do not know the name of. #renaming pandas column




 df.rename(columns={df.columns[0]:'data'},inplace=True)

Excel VBA: splitting cell values into rows

 Delimit cell values into rows. 




Public Sub delimitcell()

    Set targetRange = Range("A1")
    targetDelimiter = ";"
    Set newRange = targetRange.Offset(1, 0)
    
    For i = 0 To UBound(Split(targetRange, targetDelimiter))
        Set newRange = newRange.Offset(1, 0)
        newRange.Value = Split(targetRange, targetDelimiter)(i)
    Next
End Sub