James Stamp

James Stamp

Location Liverpool UK

Achievements

Activity

  • James Stamp made a comment

    The importance of getting the presentation of the data analysis correct in order to get the message across to the target audience. Seaborn will be really helpful in achieving this.

    I would like to learn a lot more about the abilities of Matplotlib and Seaborn

  • import pandas as pd
    import seaborn as sns
    import matplotlib.pyplot as plt

    filename = 'penguins.csv'
    data_frame = pd.read_csv(filename)
    sns.set(rc={'figure.figsize': (6, 6)})
    sns.set_style('whitegrid')
    sns.set_context('paper')

    ax = sns.scatterplot(
    data=data_frame,
    x='bill_length_mm',
    y='flipper_length_mm',
    hue='species',
    ...

  • import pandas as pd
    import seaborn as sns
    import matplotlib.pyplot as plt

    filename = 'climate.csv'
    df = pd.read_csv(filename)
    sns.scatterplot(data=df, x='City', y='Temperature')

    Correlation between City and Temperature is low

  • A very interesting article. Data storytelling has often felt like an after-thought in other data analysis courses I have took part in.

  • James Stamp made a comment

    Still getting to grips with what is possible with Pandas. I'd like to learn a lot more about the library as it appears to be a very useful and powerful analysis tool.

  • import pandas as pd
    import numpy as np
    from pandas import Series, DataFrame

    filename = '.\dataset/Brazilian-states-and-capitals.csv'
    df_flow = pd.read_csv(filename)
    ds1 = df_flow.stack()
    print(ds1.head())
    print(ds1.tail())
    ds2 = ds1.unstack()
    print(ds2.head())
    print(ds2.tail())

    1 States Acre
    Capitals Rio Branco
    2 States ...

  • import pandas as pd
    import numpy as np
    from pandas import Series, DataFrame
    df1 = pd.read_csv(".\dataset/climate.csv")
    df2 = pd.read_csv(".\dataset/Week+2.csv")
    df3 = pd.read_csv(".\dataset/Week+3.csv")
    result = pd.concat([df1, df2, df3])
    print(result)

    City Temperature Weather Year State Month Number of Fires Date Reported
    0 Rome ...

  • import pandas as pd
    import numpy as np
    from pandas import Series, DataFrame

    filename = ".\dataset/Brazilian-fire-dataset.csv"
    df_fire = pd.read_csv(filename)
    print(df_fire)

    Year State Month Number of Fires Date Reported
    0 1998 Acre January 0.0 1/01/1998
    1 1999 Acre January ...

  • James Stamp made a comment

    The Pandas library is really powerful. A lot of data manipulation can be achieved with only a few lines of code.

    I'd like to learn more about other functions available in the Pandas library.

  • States Capitals
    0 Acre Rio Branco
    1 Alagoas Maceió
    2 Amapá Macapá
    3 Amazonas Manaus
    4 Bahia Salvador
    5 Ceará Fortaleza
    6 Distrito Federal Brasília
    7 Espírito Santo Vitória
    8 Goiás Goiânia
    9 Maranhão São...

  • import pandas as pd
    import numpy as np
    from pandas import Series, DataFrame

    data = {
    'States': ['Acre', 'Alagoas', 'Amapá', 'Amazonas', 'Bahia', 'Ceará', 'Distrito Federal', 'Espírito Santo', 'Goiás', 'Maranhão'],
    'Capitals': ['Rio Branco', 'Maceió', 'Macapá', 'Manaus', 'Salvador', 'Fortaleza', 'Brasília', 'Vitória', 'Goiânia', 'São Luís'],
    ...

  • import pandas as pd
    import numpy as np
    from pandas import Series, DataFrame

    data = {
    'states': ['Acre', 'Alagoas', 'Amapá', 'Amazonas', 'Bahia', 'Ceará', 'Distrito Federal', 'Espírito Santo', 'Goiás', 'Maranhão', 'Mato Grosso',
    'Mato Grosso do Sul', 'Minas Gerais', 'Pará', 'Paraíba', 'Paraná', 'Pernambuco', 'Piauí', 'Rio de Janeiro',...

  • CODE:
    import pandas as pd
    import numpy as np
    from pandas import Series, DataFrame

    myDictionary = {'R': 'Red', 'P': 'Purple', 'G': 'Green', 'Y': 'Yellow', 'W': 'White', 'B': 'Black'}
    mySeries = Series(myDictionary)
    mySeries.name = 'House'

    print(mySeries)
    print(mySeries.values)
    print(mySeries.index)

    OUTPUT:
    R Red
    P Purple
    G ...

  • CODE
    sales = 150, 180, 200, 90, 135, 98, 'Yet to receive'
    print(sales)
    OUTPUT
    (150, 180, 200, 90, 135, 98, 'Yet to receive')

    CODE
    sales_list = list(sales)
    sales_list.append(100)
    print(sales_list)

    OUTPUT
    [150, 180, 200, 90, 135, 98, 'Yet to receive', 100]

  • Code:
    firstName = 'Lauren'
    middleName = 'Hurrier'
    lastName = 'Manual'
    print(firstName + ' ' + middleName + ' ' + lastName)

    Output:
    Lauren Hurrier Manual

  • fruit = ('apple', 'banana', 'grape')
    print(fruit)
    ('apple', 'banana', 'grape')

    False = "True"
    async = 1
    import = 10.5
    File "<ipython-input-7-f3ed83b179f6>", line 2
    async = 1
    ^
    SyntaxError: invalid syntax

    _False = "True"
    _async = 1
    _import = 10.5
    print(_False, _async, _import)
    True 1 10.5

  • My first choice would be Python for data mining and manipulation as it is quick to pick up and there are a number of good libraries that can be accessed. Would also SQL if any interactions with DBs are required.

  • I have some computing projects that use twitter data and data from some APIs. Hoping to get a better understanding of Pandas to improve the analysis and presentation of the findings

  • Hi @MacBowley(he/him), sorry about that. There was an extra character at the end of the link. Correct link is < https://pastebin.com/XYPK6SAx >

  • Eventually got it working.

    Code here for server and client files here <https://pastebin.com/XYPK6SAx>

  • Great, it worked. It is amazing how much can be achieved with only a few lines of code

  • Hi @RobBoult. Did you find a solution to this? I'm experiencing the exact same issue.

  • A very fascinating video. Really good to see.

  • A very interesting week. The presentation of the material is excellent.

  • Really good video. It's amazing how much you can do with only a few lines of code.

  • I found the computerphile video is very informative. Well worth watching

  • This is really great content. Easy to understand and follow.

  • A great introduction. Very clear and succinct

  • Hi @ChineloNwaiwu, thanks for taking the time to check out my code and providing feedback. Amended code here https://pastebin.com/5NYmggk8

    I wasn’t aware of the quit() function. I’ll check that out.

  • Hi @Andreray, thanks for information about f / format. I’ll certainly check this out.

  • Excellent course and very enjoyable. The exercises really help in understanding the concepts presented. It is amazing how much can be created with just the concepts covered on 4 weeks.

    Many thanks to all involved in creating and delivering this course.

  • RPG Info game here. There are four classes - room, item, character, rpginfo
    There is also a main program (main)

    https://pastebin.com/ZEMM10mL

    game allows the player to fight, talk, explore rooms, use items, take items dropped by enemies, check character inventory. Coding for all four challenges is included

  • James Stamp made a comment

    Update the Room class. It now has a mixture of attributes and properties
    ~~~
    class Room():
    numberOfRooms = 0

    def __init__(self,roomName):
        #object attributes
        self._name = roomName
        self._description = None
        self._items = None
        self.exits = None
        self.linkedRooms = {}
        self._character =...
    
  • Hi @FilimonDiamantidis, I found this website helpful in understanding the difference.

    In short,

    • A class method can change class variables, but cannot change instance variables
    • A static method cannot change class or instance variables

    https://realpython.com/instance-class-and-static-methods-demystified/

  • Interesting week. Coding the objects seems straightforward, but I can see it can become quite complex to maintain / debug if the objects are not designed properly.

    Are there any best practice guides as for the design of objects, specifically for methods that check / use attributes of a class? (Sometimes, I am not sure if I need a method in an object class…

  • Mini game here.
    Two characters - populate the map, a Friend and an Enemy
    Possible Actions - display, help, fight, talk, north, south, east, west, exit

    Actions
    display - display information about current room
    help - shows possible actions
    fight - fight Enemy character if they are in the room. The Friend character will not fight
    talk - character will…

  • Code for enemy class and the fight with Zach the Zombie

    https://pastebin.com/LNfFBpv2

  • ~~~
    from character import Character
    polly = Character(‘Polly’,’Poll just repeats what you say’)
    chat = True
    while chat:
    comment = input(‘Enter something to say to Polly:’).strip()
    if comment == ‘’:
    polly.set_conversation(None)
    polly.talk()
    chat = False
    else:
    polly.set_conversation(comment)

  • ~~~
    class Item():
    def init(self,roomName):
    #constructor
    #object attributes
    self.name = name
    self.description = None
    self.value = None

    def set_name(self,name):
        self.name = name
    
    def get_name(self):
        return self.name
        
    def...
    
  • ~~~
    class Room():
    def init(self,roomName):
    #object attributes
    self.name = roomName
    self.description = None
    self.items = None
    self.exits = None

    def set_description(self,description):
        self.description = description
        
    def get_description(self):
        return...
    
  • Methods
    north, south, east, west, up, down

    Attributes
    size, colour, descriptions, items, exits, description

  • Code draws 20 shapes of random size, colour and position.

    ~~~
    from shapes import Paper, Triangle, Rectangle, Oval
    from random import randint

    def getColour():
    #return a random colour string
    colours = [“red”,”orange”,”yellow”,”green”,”blue”,”indigo”,”purple”]
    colour = colours[randint(0,6)]
    return colour

    def drawRectangle():

  • James Stamp made a comment

    My Turtle race here: https://pastebin.com/99SRygZB

    Continues until a turtle reaches a finishes line (x-coord =200). Turtles have been given different upper and lower speeds

  • I really enjoyable course. The exercises really helped in understanding the concepts presented. Thanks to all involved in producing and presenting the course.

  • Binary Search is a lot quicker than the Linear Search.

    Binary search - results are always coming back as 0 seconds for lists as long as 9999999.

    Linear search - in general, the longer the list, the time taken to return a result increase

    https://pastebin.com/1Cg1bCTb

  • Various implementations of the Binary Search
    - Standard Search
    - Leftmost element if multiple matches occur
    - Rightmost element if multiple matches occur
    - Closest element if a match doesn't occur

    https://pastebin.com/71eESZ7W

  • James Stamp made a comment

    Digital Marketing is more targetable and dynamic in it's delivery methods (eg to change the recipients for a mailshot in traditional marketing would require readdressing multiple envelopes, whereas the same mailshot with emails may only take a couple of minutes to change the recipient group)

    The delivery methods are completely different. Traditional...

  • A really enjoyable. The mix and of presentations and exercises was the right level. In addition, I found the concepts / ideas were presented clearly.

    The one thing I struggled with was debugging with the Mu environment. Sometimes, it took me a bit of time to find out what a particular errors were due to not knowing my way around the IDE.

    Thanks to...

  • One additional value that could be recorded after each round is the value chosen leading to the a win or defeat.

  • Code with a statistics of win rates for each card

    https://pastebin.com/0Va4S9GD

    This version is completely automated and will produced up to 25000 card comparisons. Uncommenting the line #stat = chooseStat() within the mainLoop function will allow a person to play.

    There is also a line clearTable(conn,'result') in the main program body that, if...

  • Game code here
    - requests number of rounds and names of players
    - one player game against the computer

    https://pastebin.com/RK4RhD23

  • James Stamp made a comment

    Code to pick random card and, if different from previous card, will add to picked table.

    Code clears the picked table from entries at start of program. Program continually asks to pick another card until the user enters something other than D or Y. Entering D will display the current records from the picked table

    https://pastebin.com/uJD9BHkb

  • James Stamp made a comment

    A little application with all CRUD operations

    https://pastebin.com/i4LQUKXR

  • James Stamp made a comment

    A really great week. There was a lot of new things introduced, enough to go away and practice with.

  • Updated RPG code to check health is between 0 and 5. Anything lower than 0 or higher than 5 is highlighted as cheating

    https://pastebin.com/y17TXDxi

  • Hi @SteveSeabrook, to suppress the display of <class 'str'> <class 'float'>, remove or comment out the final print line.

    https://pastebin.com/tj3GxEpM

  • RPG code with load and save functionality. Updated the showStatus code to display the possible directions from the current position

    https://pastebin.com/f3RsB64b

  • Code to read from and write to CSV file. Had an issue with the write method creating an additional blank line after each row entry. Found a post on StackOverflow forum with one potential solution to this

    https://pastebin.com/v4NCZ7TZ

  • Hi @SteveSeabrook, the <class 'str'> <class 'float'> output is due to the line print(type(row[0]), type(row[1])) in your second with block.

  • Math Quiz with plot added.

    I need to play around with the bar chart settings and properties though as the bars are being displayed in a strange way (the higher scores are being displayed with smaller bars)

    https://pastebin.com/dG9ne5wr

  • Maths quiz with randomly generated questions. Took a bit of testing and googling to get the right python commands I wanted, but got there in the end.

    https://pastebin.com/jzG85uX3

  • Here's my attempt with randomly generated questions

    https://pastebin.com/f17Jg4pM

  • Linear sort implemented with a for loop and a while loop

    https://pastebin.com/20jMLike

  • Tested on ordered and unordered lists. Timsort is far quicker (it's always taking 0.0s unless I opt to print out the sorted list)

    On an unsorted list of 5000 items
    Bubble Sort: 11.0945
    Insertion Sort: 0.7739
    Merge Sort: 0.0074
    Tim Sort: 0.0

    Code for all functions here
    https://pastebin.com/CjvQ76H9

  • Found this one a bit more trickier to implement, but got there in the end.

    Bubble and Insertion sorts
    https://pastebin.com/AAGeYGHe

  • The more sorted the list, the quicker the bubble sort executes. However, as the length of the list grows, the length of time increases quickly for the bubble sort to finish.

  • @MarcyMitchell, thanks for sharing the book recommendation. Will check this out.

  • Good to know about the built in method for counting list elements. But it was a good exercise to build an implementation of it myself.

  • Code to get minimum, maximum and mean from a list of scores.

    https://pastebin.com/qfTr7StG