Created
September 29, 2020 11:57
-
-
Save ABcDexter/10b70f2f3494b52a15e03050b76e057a to your computer and use it in GitHub Desktop.
Pandas basic code,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################ | |
# 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