I wish to get a user to select a pandas object. Each object contains just two columns and may have a number of rows. The objects (for the sake of this question) are object1 and object2.
import pandas as pd
object1 = pd.read_csv(file1.csv)
object2 = pd.read_cdv(file2.csv)
def printTable(tableName):
# tableName.shape[0] # Gets the number of rows in the table
# len(tableName.columns) # Gets number of columns in the table
for row in range(0, tableName.shape[0]): # SHAPE is number of rows in Table
line = ""
for column in range(0, len(tableName.columns)):
line += str(tableName[list(tableName)[column]][row]) + " : "
print (line)
printTable (object1) # This works fine and prints my object
# but the following code throws an error
# "AttributeError: 'str' object has no attribute 'shape'
# How do get the User to select the object?
while True:
tableName = input("\nEnter a table name: \n")
if tableName:
printTable(tableName)
else:
break