Skip to content

Instantly share code, notes, and snippets.

@ABcDexter
Created September 29, 2020 11:57
Show Gist options
  • Save ABcDexter/10b70f2f3494b52a15e03050b76e057a to your computer and use it in GitHub Desktop.
Save ABcDexter/10b70f2f3494b52a15e03050b76e057a to your computer and use it in GitHub Desktop.
Pandas basic code,
Display the source blob
Display the rendered blob
Raw
################
# Abcdexter
import pandas as pd
# imports done
#import the data into a dataframe
data = [['A', 'B', 'C'], ['hello' , 'hello world', 0], ['cream', 'cream', 0], ['what', 'what is your name', 0], ['yolo', 'how are you', 0]]
dataFrame = pd.DataFrame.from_records(data[1:],columns=data[0])
print(dataFrame)
# print the data frame so far
# basic looping
for index, row in dataFrame.iterrows():
if str(row['A']) in str(row['B']):# print(index, row['A'], row['B'])
row['C']=row['C']+1
dataFrame.at[index,'C'] =row['C']
print(row['C'])
print(dataFrame)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment