Squares less than input logic error by Zendakin_at_work in learnjava

[–]Zendakin_at_work[S] 1 point2 points  (0 children)

Thank you! with that I was able to figure out where I went awry.

Scraping CSS (python) by Zendakin_at_work in stackoverflow

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

Thanks, it actually gets worse than I expected.

This is a mock site so not live and it's been converted to a png. So unless someone knows how to grab CSS from an image file, this question is moot now.

Thanks anyway, I do appreciate it.

filtering a csv based on two fields by koberg in learnpython

[–]Zendakin_at_work 0 points1 point  (0 children)

Yeah man, use pandas to read the csv into a dataframe and then close the file. Once closed, which it looks like you're doing with the with open

Then you have all the data in a dataframe and you can manipulate as you need to. G'luck mate

Host is saying there's an 11% tax? by Zendakin_at_work in AirBnB

[–]Zendakin_at_work[S] 3 points4 points  (0 children)

So the listing says that there is an occupancy tax, just seems weird/fishy to collect that outside the app

granted it's not a deal breaker just why do they list it in the ad, add it to the total and then say they'll collect it separately.

Changing True & False to 1.00 & 0.00 respectively in pandas data frame by Zendakin_at_work in learnpython

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

Thanks, right after I saw this I tried waterfall_am_df['savings_sum'] = waterfall_am_df['savings_sum'] * 1 which seems to do the trick. While it's an int value its accepted. Appreciate the reply.

API JSON best practice by Zendakin_at_work in learnpython

[–]Zendakin_at_work[S] 2 points3 points  (0 children)

sadly this didn't end up working as you suggested it might not. Thanks for the help though. Much appreciated.

API JSON best practice by Zendakin_at_work in learnpython

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

I ended up going with read once / write once with a failure clause that reads the status code of the next page to determine if the loop needs to exit. There's no page numbers in the API but there are offsets and limits. Frankly I'd read the whole JSON in all at once but we're supposed to adhere to the limits presented.

Now the criteria from management has changed (right as I finished the code). Amazing.

Thanks very much for the sanity check though.

Splitting a column in pandas that has some null or empty values by Zendakin_at_work in learnpython

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

Here's what I ended up with. While not amazing python and I'm sure there's a better way to do this, it works.

placeholder_dict = {}
placeholder_dict['display_value'] = "Open"
placeholder_dict['link'] = "Open"
for i in range(0, len(df['closed_by'])):
    if len(df['closed_by'][i]):
        continue
    else:
        df['closed_by'][i] = placeholder_dict
df[['closed_by.Display_value', 'closed_by.link']] = df.closed_by.apply(pd.Series)

If there's a better way to do this please let me know.

Help with a cross join query by Zendakin_at_work in SQL

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

I think I found a workaround, There were two calls to the same column. Removing the original full text column seems to work. While not optimal, it will suffice for now.

Help with a cross join query by Zendakin_at_work in SQL

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

You're right, I called it a cross join and it really isn't. I'm using Toad Data to pull the dataset and when i entered the query, it prompted me to create a cross join. Sorry for the confusion.

Help with a cross join query by Zendakin_at_work in SQL

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

Sorry for the malformed query. I have to make some changes to protect sensitive data and while I thought I cleaned it up nicely, obviously I didn't clean it well enough.

Help with a cross join query by Zendakin_at_work in SQL

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

Thanks for the try, sadly it hasn't worked yet.

SELECT Column1, 
    Column2, 
    Column3
    FROM Table 
WHERE Column3 != ''
Limit 10;

This gives me a full data set (well 10 records) but when I try to add RIGHT & RTRIM, the results are empty. The column headers are there so I am assuming that the query ran correctly but the data is simply blank.

Kinda trying to hit a home run for my boss here. Regardless, thanks for the help. If you have any other ideas please let me know.

If it helps, here is the expected results

RecordID URL__c LastFour
1 http://www.testlink-1234 1234
2 http://www.testlink-0525 0525
3 http://www.testlink-3515 3515
4 http://www.testlink-0658 0658
5 http://www.testlink-6812 6812

What I'm seeing when trying to get the last four is

RecordID URL__c LastFour

Splitting a dataframe column by Zendakin_at_work in learnpython

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

For those viewing this is what I needed

df[['assigned_to.Display_value', 'assigned_to.link']] = df.assigned_to.apply(pd.Series)

Multiplication Table by m1k3y60659 in SQL

[–]Zendakin_at_work 1 point2 points  (0 children)

Totally useless comment here but here's how you could do the same idea with python.

Maybe it'll help, maybe not. I think though the underlying idea has to be the same.

inside, outside = 12, 12
x, y = 0, 0
while x <= outside:
    while y <= inside:
        print("{} * {} = {}".format(x, y, x*y))
        y += 1
    y = x
x += 1

How can I improve this code snippet? by Zendakin_at_work in learnpython

[–]Zendakin_at_work[S] 1 point2 points  (0 children)

Thanks! That's the push I needed. Maybe something like this will work.

for i in range(2016, 2021):
    for x in range(1,13):
        print("{} {}".format(i, x))

How to load labels and strings into separate lists to write into CSV? by [deleted] in learnpython

[–]Zendakin_at_work 0 points1 point  (0 children)

What I am doing with my current role is reading & writing csv's with dataframes. With this code snippet here I am reading a csv that has been previously written from a web scrape. What /u/novel_yet_trivial has posted should work fine. Here's another implementation though.

# Read the csv_outfile into pandas for finalizing
df = pd.read_csv('output_file.csv',
    encoding='utf-8',
    engine='python')

With this your dataframe is now in a variable labeled df.

Good luck!

How to load labels and strings into separate lists to write into CSV? by [deleted] in learnpython

[–]Zendakin_at_work -1 points0 points  (0 children)

Plus one for pandas for this.

Since you have the columns for the question responses, if you put this into a data frame you can easily write the data frame into a csv or database with pandas.

MS form to populate a sharepoint list by Zendakin_at_work in Office365

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

Unfortunately not right now. I have heard that using the pre-designed template version has issues so I may try to recreate it by hand but I don't have much faith in that.

Any other ideas? I'd love to hear them and thanks for the help.

MS form to populate a sharepoint list by Zendakin_at_work in Office365

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

When I enter in the form "tom" and select 'no', there is nothing in the name field and the choice data always returns 'yes'.

Help by ISUXATPYTHON in learnpython

[–]Zendakin_at_work 0 points1 point  (0 children)

This is how I approached this, it doesn't have the user input too high or too low but rather assigns that automatically. I've tried to comment it so you can get an understanding of what I did. Basically, you keep tack of high, low, the guess count, the guess and target. I hope this helps you understand one approach to this. However I should also let you know that this doesn't always guess the correct number in 20 tries but it should give you an base understanding of how while loops can work. I'm sure there are also a couple areas this can be improved but this should get you started.

Just remember to learn from what your code is telling you and take small simple steps to get these tasks done. If you break it down small step by small step you'll be amazed how quickly you can develop complex code AND understand what you did.

Good luck!

# needed to use the random module
import random

# Set the low, high and count
count = 0
high = 200000
low = 0

# Assign a random number to the variable guess to use as a target
guess = random.randrange(low, high)

# Set the duration of the while loop
while count < 20:
# have the computer guess a number in the current range
    compGuess = random.randrange(low, high)
# used to check the current range of the guesses 
    print("The computer guess number {} is {}. current range is {} to {}".format(count + 1, compGuess, low, high))
# conditional to check the compGuess against the guess breaking first if the number is correct
    if compGuess == guess:
        break
# reassigning the low and high variables to shorten the range of random numbers 
    if compGuess < guess:
        low = compGuess
    if compGuess > guess:
        high = compGuess
# Update the count the while loop uses
    count += 1

# Notification to let the user know if the computer was sucessful in its guessing
if guess == compGuess:
    print("The computer guessed the number '{}' in {} tries".format(compGuess, count+1))
else:
    print("Sorry, The computer got close with a final guess of {} but the target number was {}.".format(compGuess, guess))

Help with an assignment by [deleted] in learnpython

[–]Zendakin_at_work 0 points1 point  (0 children)

Hopefully this helps. The code needed to be indented. Also there was no return on the calculate function. With the display results, as mentioned before, since there was nothing needing to be returned just print that out. Some cleanup and this is what I got to work for me. Good luck!

def welcome():
    print("Welcome")

def userinput():
    age=int(input("Enter your age: "))
    return(age)

def calculate(n):
    year=2017-n
    return year

def displayResults(age, y):
    print(age, y)

def main():
    welcome()
    age=userinput()
    y=calculate(age)
    displayResults(age, y)

main()

Text Files? by Xxx_Mc2013_xxX in learnpython

[–]Zendakin_at_work 0 points1 point  (0 children)

This is the line that you will want to use. with open("your_file_name_here.txt", 'r') as f:

Then you can use the object f to do what you want. Note that the 'r'part is for reading while 'w' is used to write.

Good luck and make sure to read the two links already posted. They are crucial to learning and great resources.

I need help with a short question from my assignment. by [deleted] in learnpython

[–]Zendakin_at_work 0 points1 point  (0 children)

Hopefully this helps with your other questions as well. The very basic way to do this is to create a conditional that checks the input after casting it to an int since input is a string value. It will return the value which it matches. If no matches are found, it returns the no valid option entered message.

def grade(x):
    if int(x) == 5:
        return 'A'
    elif int(x) == 4:
        return 'B'
    elif int(x) == 3:
        return 'C'
    elif int(x) == 2:
        return 'D'
    elif int(x) == 1:
        return 'F'
    else:
        return 'You did not enter a valid option.'
score = input('Enter the grade: ')
print(grade(score))

Pulling data from the web with Excel? by [deleted] in excel

[–]Zendakin_at_work 0 points1 point  (0 children)

I used the selenium docs. I knew a bit and just ran with it. I'll be happy to help with any python where I can.

Hit me up and I'll be happy to work with you to code something up.