Beispiel #1
0
def main():
    #Load the countries.csv file (located in the assignment9 repository) into a pandas DataFrame and name this data set countries.
    countries = pd.read_csv('../countries.csv', index_col = 0)
    #Load the indicator gapminder gdp_per_capita_ppp.xlsx data set (located in the assignment9 repository) into a DataFrame called income.
    income = pd.read_excel('../indicator gapminder gdp_per_capita_ppp.xlsx',index_col=0)
    #The program should transform the data set to have years as the rows and countries as the columns, then show the head of this data set when it is loaded.
    incomeTrans = income.transpose()
    print("show the head of this data set when it is loaded:\n")
    print(incomeTrans.head())
    print("has showed the head of this data set:\n")
    #build a class object
    incomeData = DataAnalysis(income, countries)
    
    #The program should ask the user to enter a year, then display the graph using the function in question 4. Continue asking the user for a year and displaying the graph until the string ‘finish’ is entered.
    while True:
        try:
            #ask the user to enter a year
            inp = input("Input a year please, enter 'finish' to quit\n")
            if inp == 'finish':
                break
            years = validYears(inp)
            #graphically display the distribution of income per person across all countries in the world for the given year
            incomeData.distribution_income(years)
        #Invalid user input is handled correctly (when input is required by the assignment)
        #User defined exception(s) are employed for indicating error conditions rather than raising generic exceptions
        except InvalidInputException:
            # Exit if the user enter invalid input
            print("Invalid input")
        #sys.exit(0)
        except KeyboardInterrupt:
            # Exit if the user enter Ctrl+C
            sys.exit(0)
            print("Quited  by user")
        except EOFError:
            # Exit if the user enter Ctrl+D
            print("Quited  by user")
            sys.exit(0)
        except:
            print('exception happens')
    
    #use the class from question 6 to generate graphs for the years 2007-2012
    for year in range(2007, 2013):
        incomeData.generate_graphs(year)
Beispiel #2
0
def main():
    #Load the countries.csv file (located in the assignment9 repository) into a pandas DataFrame and name this data set countries.
    countries = pd.read_csv('../countries.csv', index_col=0)
    #Load the indicator gapminder gdp_per_capita_ppp.xlsx data set (located in the assignment9 repository) into a DataFrame called income.
    income = pd.read_excel('../indicator gapminder gdp_per_capita_ppp.xlsx',
                           index_col=0)
    #The program should transform the data set to have years as the rows and countries as the columns, then show the head of this data set when it is loaded.
    incomeTrans = income.transpose()
    print("show the head of this data set when it is loaded:\n")
    print(incomeTrans.head())
    print("has showed the head of this data set:\n")
    #build a class object
    incomeData = DataAnalysis(income, countries)

    #The program should ask the user to enter a year, then display the graph using the function in question 4. Continue asking the user for a year and displaying the graph until the string ‘finish’ is entered.
    while True:
        try:
            #ask the user to enter a year
            inp = input("Input a year please, enter 'finish' to quit\n")
            if inp == 'finish':
                break
            years = validYears(inp)
            #graphically display the distribution of income per person across all countries in the world for the given year
            incomeData.distribution_income(years)
        #Invalid user input is handled correctly (when input is required by the assignment)
        #User defined exception(s) are employed for indicating error conditions rather than raising generic exceptions
        except InvalidInputException:
            # Exit if the user enter invalid input
            print("Invalid input")
        #sys.exit(0)
        except KeyboardInterrupt:
            # Exit if the user enter Ctrl+C
            sys.exit(0)
            print("Quited  by user")
        except EOFError:
            # Exit if the user enter Ctrl+D
            print("Quited  by user")
            sys.exit(0)
        except:
            print('exception happens')

    #use the class from question 6 to generate graphs for the years 2007-2012
    for year in range(2007, 2013):
        incomeData.generate_graphs(year)
Beispiel #3
0
#list should correspond to the same index in every other list.
#The strings tell you were to start looking for each field and where to end.
dateList = getFieldList(ratingsList, "<div class=\"date\">", "</div>")
qualList = getFieldList(ratingsList, "Quality\">", " Quality")
easeList = getFieldList(ratingsList, "Easiness</strong><span>", "<")
helpList = getFieldList(ratingsList, "Helpfulness</strong><span>", "<")
clarList = getFieldList(ratingsList, "Clarity</strong><span>", "<")
intrList = getFieldList(ratingsList, "Interest</strong><span>", "<")
commList = getFieldList(ratingsList, "\"commentText\">", "<")    

#Builds the review lists out of all of our lists of dates, lists of qualities, etc.
reviewList = createReviewList(dateList, qualList, easeList, helpList, clarList, intrList, commList)

#Creates a DataAnalysis object using the person we created above and a list of
#Review objects holding all of the data from their reviews
dataAnalyzer = DataAnalysis(currentPerson, reviewList)

#------------------PRINTING-------------------------------------------------------------------

#Prints out the professor/person data.
print "\n\n"
print "--------Professor summary"
currentPerson.toString()
print "\n\n"

#Prints out all the review data.
'''for item in reviewList:
    item.toString()
    print "\n"'''
#Prints out the first review.
print "--------Example review"
Beispiel #4
0
                os.remove(fullPath + pic)

instagram = ModifiedInsta()
instagram.with_credentials(MAINUSERNAME, MAINPASSWORD)

#First Parameter MainUser. 2nd Parameter Followers/Followings

instagram.fromScratch(
    "INSTAGRAMUSER", 0, 1, 100, 100
)  #Pass 0 to check most recent followers, pass 1 for most recent followings

##instagram.furtherAggregate("EXISTINGDB.db",0,30)  #Keep collecting data using existing database

#instagram.setDbName("1586871777.db")

dataObject = DataAnalysis(instagram.dbName)

dataObject.networkGraphText(
    1, 1)  #Not all pictures are being downloaded to save time

instagram.getPhotoData()  #downloads profile pictures of needed users

instagram.imageProcessing()  #Adds the alpha channel to profile pictures

#Wenn man eine Zahl(Int) übergibt als 2. Parameter werden alle Follower die threshold<=Zahl Connections haben aus dem Graphen geworfen (Standardmäßig 0 damit keiner verloren geht)

dataObject.networkGraph(
    1, 1
)  # Bei 00, 10 mode=0, Bei 11, 01 mode=1 -> Databasestructure changes based parameters given before the graphing happens
#instagram.additionalUserInfo()  #Gets follower-,follwings- and mediacount for all necessary users