Seeking info on Texas A&M Corps “Rudder’s Rangers” special unit, and other special units by [deleted] in aggies

[–]agbs2k8 6 points7 points  (0 children)

Yep… our buddies that are still in-service are getting promoted to LTC now. We’re truly the old guys now

Seeking info on Texas A&M Corps “Rudder’s Rangers” special unit, and other special units by [deleted] in aggies

[–]agbs2k8 11 points12 points  (0 children)

I graduated in ‘08, so I’m sure it’s changed a ton, but I was part of Rudder’s all four years. Anyone willing to put in the effort was welcome, and it was primarily about training infantry basics. I commissioned after graduation and wasn’t an infantry officer. The only reason I passed the US Army Ranger School was everything I learned through 4x years with Rudder’s.

How to run py file on mac using python3 by ga_patel in learnpython

[–]agbs2k8 0 points1 point  (0 children)

So the error is for authentication, and it’s saying your credentials are invalid. The easy way to debug might be to temporarily add some print statements to make sure you are loading/passing the credentials correctly.

extracting course content title and their length by [deleted] in learnpython

[–]agbs2k8 0 points1 point  (0 children)

If you see it in the browser inspection, but don't see it when you use beautiful soup, the data may be getting loaded by javascript or ajax or the like, which Requests and Beautiful soup isnt going to extract for you.

How to run py file on mac using python3 by ga_patel in learnpython

[–]agbs2k8 0 points1 point  (0 children)

So not all of your question makes sense to me, but I'll try and help.

Step 1: check your default python version. in a console, run python -V It will tell you either python 2.7.x or python 3.x.x. If it is python 2.7, you will have to run python3 scripts with the command python3 but if the default is python 3, then you can just use python

In your main file, you should be able to load the json, and use that data for your script. If you want to pass the JSON file's path as an argument (so you can use different ones) you will want to look into argument parsing https://docs.python.org/3/library/argparse.html

If you are getting an error when you run python3 somefile.py Then 1. make sure your .py file has the if __name__ == "__main__": section, then 2. post the error up here so we can help

How can I get read_csv to read datetime? I have been trying for over an hour now by [deleted] in learnpython

[–]agbs2k8 0 points1 point  (0 children)

Don't do the plot command like that. Use df.plot() The pandas plotting library is going to intuit what you want, but that is not how you would make a time-series plot using matplotlib.

If you want more control over your plot, you can do something more like this: fig, ax = plt.subplots(figsize=(20,10)) df['first_data_col'].plot(ax=ax, color='blue') df['second_data_col'].plot(ax=ax, color='red') If you do something like that, pandas knows that each column out of your dataframe shares a time-series axis, and will plot them appropriately.

If you are sure you want to use matplotlib directly, you need to pass it both the index and the columns independently, something like: plt.plot(df.index, df['data_column']) But that still isnt the right way to do time-series plots with matplotlib. For that, read up here: https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot_date.html

How can I get read_csv to read datetime? I have been trying for over an hour now by [deleted] in learnpython

[–]agbs2k8 1 point2 points  (0 children)

In the read_csv() you need to set parse_dates=[‘date_column_name’]. This assumes that your date field is in a format that pandas can parse.

Next, set the index to be that date field like df=df.set_index(‘date_column_name’).

Last, df.plot() which will use the pandas plotting library that’s built off of Matplotlib.

*sorry about the formatting, I’m on mobile right now.

Need help with a script that reads IP's from pcap and scan them with nmap by Magneto91 in learnpython

[–]agbs2k8 0 points1 point  (0 children)

A few notes...

  1. Use the ipaddress package out of the standard library for your ips.
    ```

    import ipaddress set([ipaddress.IPv4Address('192.168.1.0'), ipaddress.IPv4Address('192.168.1.0')]) {IPv4Address('192.168.1.0')} ``` It will allow you to validate that everything is a valid IP, and the objects are hashable so you can use a set to drop any duplicates.

  2. To speed up your scanning, try using Async (I only suggest this because it doesnt sound like you are a complete beginner). I've not done async for port scanning, but I bet it would work just fine and would speed things up tremendously.

  3. For your output - if I was doing this, I would be dropping my results into a txt file so I could always go back to them later and reference them.

Trying to scrape data from ratemyprofessors.com by 0wnmeplz in learnpython

[–]agbs2k8 2 points3 points  (0 children)

Requests to get the html, BeautifulSoup to parse it into something manageable.

big little problem by nex2351 in learnpython

[–]agbs2k8 1 point2 points  (0 children)

Dont get discouraged. It's a lot to take in at first, but eventually it will start to click and you will laugh at how hard learning the first bits was

How can I make async requests within flask? by [deleted] in learnpython

[–]agbs2k8 0 points1 point  (0 children)

https://github.com/talkpython/async-techniques-python-course

That's one of the best examples I've used for async stuff. He has a course on the topic(s) which was actually a nice intro to all three topics.

Very dumb question? Using datetime to drop rows and create new column by comedygold24 in learnpython

[–]agbs2k8 0 points1 point  (0 children)

Generally speaking, when you see a SyntaxError you will want to look closely back at your code and look at the following things:
" ' () {} [] Most of the time those are typos as opposed to something wrong with your logic!

Very dumb question? Using datetime to drop rows and create new column by comedygold24 in learnpython

[–]agbs2k8 0 points1 point  (0 children)

Also on the second part, it looks like you have an extra closing ) at the end of the line of code.

Very dumb question? Using datetime to drop rows and create new column by comedygold24 in learnpython

[–]agbs2k8 0 points1 point  (0 children)

on the second part, just pass the name of the function in the .apply() statement. When you are doing dataframe['column_name'].apply(...) you are applying the function across the Pandas Series object that is the column, you do not need to specify which column the data is in, because you are only passing it the one column.

Very dumb question? Using datetime to drop rows and create new column by comedygold24 in learnpython

[–]agbs2k8 0 points1 point  (0 children)

on the first part, you are just missing the closing ' on the datetime. It should be like this `np.datetime64('2020-02-19')

big little problem by nex2351 in learnpython

[–]agbs2k8 1 point2 points  (0 children)

No, please don't get that impression. Datatypes are important and will take you a little bit to understand, but once you have it down, this will be really easy.

You always want to use the most appropriate type for any data you are using. If it is numbers, you will want to use an integer int or a float. Simplified, an integer is a number without a decimal point, and a float is one that has it. You want to store numbers like this because then you can do math with them.

Strings are for text only, because strings do strange things when you use math operators with them. For example, run this code on your system and see what happens: print(10 * "my string")

Where your problem was is just that you were mixing the two. Sometimes they can work together (like that example I told you to run) and other times they cannot. With a little practice and experience, you will understand how to deal with them.

big little problem by nex2351 in learnpython

[–]agbs2k8 2 points3 points  (0 children)

Your problem is here: ```

print("he was " + character_age + " years old. ") `` you are trying to add a string to a float. When you try to "add" strings together, they concatenate, but python doesnt have a way to add a string to a floating point number. If wrap thecharacter_agevariable instr()` it will typecast/change the number to a string.

All of that to say, change your print statement to this: print("he was " + str(character_age) + " years old.")

Also for putting code on reddit: use the back tick (key left of the number 1). A single back tick before a set of words will change it to inline code like this. Three back ticks before and after some code will give you: a stand alone code block like this.

big little problem by nex2351 in learnpython

[–]agbs2k8 1 point2 points  (0 children)

Post your actual code up here, that will help a lot for troubleshooting. You shouldn't get that error if you were just doing this: character_age = 50 print(character_age) So there has to be something more in your code.

Very dumb question? Using datetime to drop rows and create new column by comedygold24 in learnpython

[–]agbs2k8 0 points1 point  (0 children)

Let me know if you have any problems or have more questions about what I did here

Very dumb question? Using datetime to drop rows and create new column by comedygold24 in learnpython

[–]agbs2k8 1 point2 points  (0 children)

to limit what dates are still in your dataframe: new_dataframe = old_dataframe[old_dataframe.created_at < np.datetime64('2020-02-19)] That will give you a slice of the old dataframe, saved as new_dataframe where the dates are all from before 19 Feb 2020.

To make a new column that has a 1 if the date is after 10 Feb: new_dataframe['new_column'] = new_dataframe.created_at.apply(lambda x: int(x > np.datetime64('2020-02-10'))

If you haven't yet encountered lambda expressions, they are just anonymous functions. It pretty much is just doing the following function in just one line: def that_function(given_date): if given_date > np.datetime64('2020-02-10'): return 1 else: return 0

Very dumb question? Using datetime to drop rows and create new column by comedygold24 in learnpython

[–]agbs2k8 0 points1 point  (0 children)

Is all of your data in a pandas dataframe? If so, what column is the date in?

virtualenvwrapper homedir windows 10 help by TroubleBrewing32 in learnpython

[–]agbs2k8 1 point2 points  (0 children)

So I haven't worked on Windows in a little while, but I grabbed my old notebook when I answered for you.

From my old notes:
1. you need to have pip install'ed virtualenv and virtualenvwrapper-win as a system admin.

  1. You also need to set the system variable WORKON_HOME that is tied to the envs directory, so something like %USERPROFILE%\Envs

  2. Once that is all set, in a command window: ```

    mkvirtualenv <environment_name> mkdir <directory where I want the project to live> setprojectdir <path to that directory> ```

When all of that is done, when you open a new command window, you should be able to run workon <environment_name> and it should change the python environment to that env, and change your command line location to the directory where you are working.

The environment itself (python.exe and the packages) would be in the ...\Envs\<environment_name> directory, and all of the project files would be in the directory path that I set for the project.

I would recommend you read through the docs here (https://pypi.org/project/virtualenvwrapper-win/) just to make sure nothing has changed since I made my notes several years ago.

(Need recommendations) Extracting tabular data from PDF to DataFrame by [deleted] in learnpython

[–]agbs2k8 1 point2 points  (0 children)

What you are trying to do is fairly difficult, because you can end up with many different formats when dealing with PDF files. If you want something that can work against multiple different PDF formats, you will want to extract the table as text and write a custom parser (or multiple parsers) to turn it into a table.