r/learnpython • • Sep 18 '23

Why does Python seem so complicated?

First, a little background. I've been using Excel for ages now, about 15 years now with a large increase in the last 5 years. Mainly functions and visuals, a small bit of optimization and a tiny bit of VBA. I'm more than comfortable with vlookup, and our work computers aren't updated so I haven't had much opportunity to use xlookup. I've made things with the sort, filter, and offset function to include conditional formatting as study aides for GRE study resource. Within my current field, I'm considered a wizard, however, against true wizards I'd be a novice. But I can use it very efficiently and relatively easily.

I'm in the process of switching careers, and as part of that I'm learning Python. I'm in a course that had us do some courses in DataCamp to help learn Python. I completed the courses, but it was mainly brute forcing my way through. I'm going back through and trying to recreate much of the items we went over to make sure I 'get it'.

I've been using ChatGPT to help me along the way, and I can generally get what I need, but I have no understanding of what I'm actually doing. And that's my problem. In Excel, I understood exactly what I was doing and could effectively trouble shoot any issue I ran into.

With Python, I'm stuck using ChatGPT, and if ChatGPT can't solve it then I can't seem to do anything. It just doesn't make sense to me. I have numpy, pandas, openpxl installed. I even tried doing some web scraping with selenium, which I was able to get it to open a web page, but nothing beyond that. That one I was definitely reaching too far on, and I get that, but I use it to show I feel like I'm a decent trouble shooter.

Maybe I'm overestimating my abilities, but I just cant get an understanding of how to effectively use Python. I feel like I have to envision every single aspect of what I'm doing, and as someone who isn't a very visual thinker, that basically means I need a separate log of anything I'm doing before I do anything. And the feels anti-productive.

I loaded a file into Python and there are two columns of data I was trying to turn into arrays. That took me like an hour to get done and I ended up turning them into values rather than arrays. Actually, I suppose it was a bit of both, but it just seems needlessly complicated to try and understand what I'm doing.

How do you keep track of what you're doing? Using things like .head I thought might be helpful, but there are mixes of blank and empty data. It has over 2000 rows and a quick visual of it makes it even more complicated to look at it. Is it best just to accept I'll use ChatGPT without understanding?

0 Upvotes

47 comments sorted by

59

u/[deleted] Sep 18 '23

I think the problem is using ChatGPT because it’s notorious for giving bullshit code and for a beginner to be using it is like the blind leading the blind

-5

u/Sonoshitthereiwas Sep 18 '23

I hear what you’re saying, but I only use ChatGPT when I’m not sure what to do. I don’t even think I’m doing complicated things. Give me 2 minutes and I could easily teach this in Excel, but I can’t even figure it out after like 30-45 minutes in Python.

I mean, I get it done, but it’s repeated behavior as opposed to learned. Im typing things, but I don’t retain any of the info not fully understand what it’s doing or how it works.

2

u/Majoishere Sep 19 '23

ChatGPT is good for answering simple questions like "what does this function do?", but if you ask for a code, not only will it be most likely incorrect, but you won't learn a thing, so the debugging is going to be hell.

Just take your time and learn it properly. ChatGPT is a good search engine, but a terrible coworker

1

u/Sonoshitthereiwas Sep 19 '23

That’s generally what I’m using it for now. Well, that and explaining how parts of a function go together.

I still struggle with columns and rows such as trying to get or add to arrays. It either feels backwards or confusing, so I have to ask which order do I put things in, like if I just want the first stack vs the second stack.

Just a basic guide, how does ‘this small component’ work type of thing, as opposed to give me x code to accomplish g.

32

u/nightdeathrider Sep 18 '23

try looking for answers in Stack overflow instead of chat gpt, chances are someone has had your question already and a real human have answered it with more context/real explanation. Start reading documentation from methods and functions that you come across in different libraries and add them in your toolbox.

16

u/amutualravishment Sep 19 '23

Needing 30-45min to do something simple in Python is part of the learning curve, just keep learning until you are accustomed to the Python tool set you are using. Eventually it becomes a common thing to spend merely a couple hours on some code that automates thousands of hours of work, it ends up being a really good trade off if you stick with it and learn the bits of code.

5

u/Dex_LV Sep 19 '23

In the beginning I would suggest to actually read python documentation or take some online courses, for example CS50P is free. But, if you still want to use chatGPT, don't ask to solve the problem. Ask how to do very specific small actions so the main task isn't known to chatGPT. Ask very short and simple questions. For example how to open file or how to sort list Chatgpt will give some example with some function. Then ask to explain that function.

5

u/Naive_Programmer_232 Sep 18 '23 edited Sep 18 '23

Well the jump from excel to a programming language is big, in that with excel you get this full blown application that understands how to do all these things so you can get more done with less, but with python and other programming languages, it's more or less like a big tool box of a bunch of loose parts you figure out over time how to connect to get shit working. Some struggle is to be expected though, you gotta learn how to think when it comes to code, its a different mind set. Each thing that seems practical in excel to use, is going to need to be broken down step by step into pieces where you'll have to call certain functions / methods and so on in order to do 1 thing. That's just how things tend to be organized and compartmentalized in code, its like taking a big project and breaking it all down into small pieces, and the code you look at is how all those little pieces connect.

I wouldn't memorize. Not saying to not rely on chatgpt either because it's a great tool and should be used. But another thing you could do, which helped me in the end, is learn how to read documentation and look stuff up. A lot of times, when you watch tutorials and their using libraries and its doing so and so, etc. these people are referring to documentation before hand so they know what to say in the video lol. They aren't guessing at what something does and coming up with some theory of how it works. They're digging into documentation and seeing it for themselves from the providers of the tool. So, that could be something you could try to incorporate, use tools like the help function even to get an idea of how things look in documentation, learn the conventions, what things are called, and how to look stuff up and interpret. Over time, you'll naturally memorize some of this, but try not to make it a goal to memorize all of it, because it's all there, just waiting for a google to see the docs ya know. You don't have to waste your time with it, because if you need the tool, you'll have to look up the docs anyway. Its a good thing to get into the habit of.

Lastly, be practicing frequently. Don't just sit there and watch video after video without applying it, cause it probably won't stick. And it sounds like you're already doing this, which is good. But just keep at it and challenging yourself. Over time, you'll narrow down a grind that works for you and you'll learn how to learn better

3

u/Sonoshitthereiwas Sep 18 '23

Practice is exactly my hurdle. That’s why I’m loading data from excel using pandas. I’m using some of my old datasets to practice recreating. This way I know what the outcome is supposed to be.

The DataCamp environment comes preloaded with data, but I can’t recreat that and that’s part of my struggle. I don’t learn well from videos at all. I feel like I can modify code, but I can’t write or create code.

I also might be overestimating my abilities because I’ve only seen code that’s maybe half a page to a page long.

You’re right though, I guess I just wasn’t expecting this big of a jump. Because I keep hearing how intuitive Python is, but with a background in Excel it just doesn’t feel intuitive to me. And this makes me question if I’m doing something wrong or just inept.

But I think I just need to take a step back and just kind of keep hammering away. I think it might be a good idea to modify my datasets though. All of the data I received in the last required significant cleanup and that just doesn’t work here. At least not yet and not at my level.

Thanks

1

u/minvestem Sep 18 '23

Practice, where? There's lots of people offering video courses out there, but not many exercises.

1

u/Sonoshitthereiwas Sep 19 '23

This is exactly the issue I’m having. I’m trying to practice by loading a data set, but I’ve come to realize the dataset I have isn’t good enough for basic use.

I’m going to simplify a dataset I have and parse it into chunks and then try using that.

2

u/Naive_Programmer_232 Sep 18 '23

That’s the other tricky part. You need to make up the exercises or find something interesting you’d like to do that is about your skill level. And more often than not, even simple ideas can be complicated in terms of what needs to be done. That standard has been set for years it’s a thing we’ve all been around and played a part in, using different software and apps. But yeah that’s a tricky situation cause you don’t know what you don’t know and yet you’re trying to progress without overwhelming yourself.

1

u/minvestem Sep 19 '23

I'm aware of the difficulty, that's why I asked.

1

u/Naive_Programmer_232 Sep 19 '23

Regardless of difficulty, the whole programming learning thing is about self-teaching. No matter which way you wanna spin it, there is no one resource to learn from. There's always a diversity. I even went to college for comp sci, same thing there. It's a thing you just need to learn to deal with. Constant, real learning, is something tech professionals need to roll with afaik that's just how it is. Teach yourself, or you can't adapt and bust. That's the game.

2

u/minvestem Sep 20 '23

Again, I'm well aware, I've done courses, many of them, there's never much to practice on, sometimes nothing at all. So, where do I find stuff to practice on.

It's all well and good telling us to do the blindingly obvious. How? Where?

1

u/Naive_Programmer_232 Sep 20 '23

You make stuff up to practice on. Come up with ideas of stuff you’d like to make and build them. And you also practice leetcode and those sorts of problems as they’re common for interviews. That’s about what I’ve gathered.

2

u/minvestem Sep 20 '23

As the person who originally asked the question pointed out in a fair amount of detail, building things you are interested in is a very lopsided, uneven, unpredictable way to approach this.

Interview questions I can see being useful, though limited, but I'll be having a search for leetcode.

Basically you're unaware of any better suggestion? You still pointed it out as something we should be doing despite as far as you're aware there being nowhere it CAN be done?

Forgive me for being confused and remaining frustrated.

1

u/Naive_Programmer_232 Sep 21 '23 edited Sep 21 '23

I guess I’m not that helpful. I’m sorry, I tried. I realize now my response doesn’t really make sense with this post. Maybe I was confused haha. Sorry about that

3

u/[deleted] Sep 19 '23

Do not use ChatGpt! This is a tool that can help, but over using it will lead to dependance, as you've seen.

I think you're not proficient enough to do what you want to do. Best to learn how to walk before you learn how to run. Implement some simple functions like, fizz buzz, sum from 0 to 100, sum the even numbers from 0 to n, etc.

Practice loops, working with ints, arrays, strings, etc. Do not use "fancy" tools like list compressions (you'll get there eventually).

Opening files and reading them is non trivial, if the file is not a format you can easily parse. Consider using a data base, not files.

1

u/Sonoshitthereiwas Sep 19 '23

I think I was trying to run without realizing I was trying to run, if that makes sense.

I thought what I was doing was basic stuff, but looks like maybe I jumped without realizing it.

2

u/HomeGrownCoder Sep 19 '23

Start guided with python basics. There is a big swing imo from vba to python.

I think you are overestimating how much is directly transferable from vba.

1

u/Sonoshitthereiwas Sep 19 '23

I’m actually not a big fan of VBA. I mean, I see the use for sure, but our work systems cause so many issues with it, it wasn’t worth investing too much time in.

I am getting the feeling I put too much investment in hearing everyone say how easy Python is a coding language.

1

u/HomeGrownCoder Sep 19 '23

Yeah it’s relative easier compared to other modern languages maybe… but VBA has some dust in those bones. ;)

2

u/pixieshit Sep 19 '23

Maybe it's the course you're doing? I've only just started my learning but I did one course which made me go ??? wtf is happening.

I started learning from automatetheboringstuff.com and it's been so much clearer. Why? Because it teaches Python from first principles instead of introducing rules without explaining them. Once you know first principles you can construct what you want easier.

1

u/Sonoshitthereiwas Sep 19 '23

I’ll check that out.

Thanks!

2

u/Rawing7 Sep 19 '23

Something nobody seems to have brought up yet is that python is a completely different programming paradigm than excel. Excel is declarative programming: You write a formula, and the formula always keeps the cell up-to-date. But python is imperative programming: You have to give it instructions to execute, one after another. After 15 years, it's hardly surprising if it takes you a while to adapt.

1

u/Sonoshitthereiwas Sep 19 '23

This is definitely one of the things I’m struggling with

2

u/AKdemy Sep 18 '23

So you started using Excel 15 years ago and have used it heavily for 5 years. Now, you complain that Python is hard because you struggle with the basics?

I have several decades of experience in my mother tongue and find it relatively easy to use. English is my second language, which I am relatively comfortable with as well. My ex wife is Canadian, and I have worked in London for several years by now. My kids consider English their first language as well. I lived in Hong Kong for a while and tried to learn some Cantonese. Somehow I found it really hard to order food, even after studying for a few weekends and the language seems so complicated. Yet, everyone growing up there seems to be able to comprehend the language....

On a more serious note (although the above is true and probably illustrates it best), I heavily use(d) the following programming languages (Python, Java, Julia, Matlab/ Octave, OCAML, SQL, R, Stata, EViews, SPSS, basic C and C+ ,and JavaScript) at work. For several years, I didn't have to use Excel much, if at all.

I don't think excel is complicated, but I am just not used to it and so much faster using computer code as opposed to trying to drag and drop stuff into pivot tables and the like.

1

u/Sonoshitthereiwas Sep 19 '23

I see what you’re trying to say, but I wouldn’t say they are quite connected.

In the sense of languages, to try to equivocate it:

Learning French as an English speaker:

Bonjour

Hello

Comment cava?

How are you

Je bien

I am well

Au revoir

Goodbye

This is more closer to formal greetings of course where someone more familiar with the language might give something like

Sup

Cava

Aight

Bon

Peace

head nod

Pivot tables are a day 1 basic excel task. Pivot tables are for those who don’t know what they’re doing. I’ve done Hello, but am stuck moving beyond that.

Perhaps my expectations exceed my reach, you may very well be accurate in that sense. But I am still frustrated nonetheless.

3

u/czar_el Sep 19 '23

Excel is a spreadsheet program with a GUI interface that allows you to do a single function at a time, or multiple functions if you nest them. It also allows you to specify the cells you're applying the function(s) to.

Those activities are a very small subset of what a coding language like Python does. To answer your post title question: Python isn't complicated, coding is complicated compared to Excel. Coding languages don't hold your hand like a GUI spreadsheet program does (e.g. for selecting data files, launching commands, handling filepaths, saving results, selecting sheets and cells, etc), coding languages are the underlying commands that a GUI handles for you without you knowing

An analogy is that you've been a train conductor for years and have been good at it. You think to yourself "trains have wheels, and cars do too, I'd be a great car driver!" But if you've never driven a car before, you quickly find out your train experience doesn't exactly prepare you as well as you thought, since you've never had to steer before, or consider road types, or deal with pedals and shifters. Excel is on rails, because the GUI does so much of the steering and other work for you. Python has no rails, you can go wherever you want, but it's significantly more comex to know how to get there.

Bottom line, yes, you overstated your abilities. Excel wizard does not equal coding wizard. They're different skillsets. I was in the same boat as you years ago. I was the Excel and VBA guy in an org full of non-tech people, and wowed the pants off them. I made the pivot to coding languages, but it took years of actual study (e.g. books, courses, and even grad school), not asking ChatGPT, which others have already warned you is unreliable and will not teach you fundamentals even when it does not return errors. Humble yourself a bit and start at the basics from an actual curriculum. Don't rely on ChatGPT while you learn. Use it as an idea generator when you have the skill to evaluate whether its results are accurate or not. But to use it when you can't evaluate it is a way to cause problems for yourself down the line.

3

u/[deleted] Sep 19 '23

When you program an Excel spreadsheet, you have a model of state that you can see - the rows, columns, cells, and contents of the spreadsheet itself. You make changes, you see the changes. The code's harder to read but it matters less because it's easier to see what the code does.

When you write code in Python, there's a model of state as well, but it's implicit - you can only interact with it via the Python language, you can't "eyeball" it (well, you can - with a debugger) and to some extent the model of state is something you have to keep track of in your head.

Python's simpler than VBA by far, but programming is harder than spreadsheet scripting.

Stop using ChatGPT, though.

1

u/Robswc robswc Sep 19 '23

It sounds like you just need to learn the foundations and then you'll get it!

Just start with variable assignment, types and then functions and go from there :)

I know it can be daunting at first but it'll be well worth it. I'll echo what others have said. Don't use ChatGPT unless you know what you're asking. Otherwise, the answer will just be 42 ;)

1

u/neiliodabomb Sep 19 '23

There’s a free course on FreeCodeCamp.org that teaches data analysis with Python/Pandas/Matplotlib/Numpy. They even have practical exercises at the end.

https://www.freecodecamp.org/learn/data-analysis-with-python/#data-analysis-with-python-projects

1

u/KM130 Sep 19 '23

I am also a heavy Excel user but I am also using VBA a lot. For a project I needed to learn Python as I couldn't do it with excel/VBA.

My experience was that from VBA is easy to jump to Python as they share similar logic.

I found that there is a steep learning curve as I found my self going back to what I know to do best which is Excel/VBA.

Two years on and after I finished a couple of projects I wished a learned python earlier.

My advice is start from the beginning get a book for beginners and start slow. You will get there eventually. Also it helps if you have a project and an end goal so that you don't feel that you are doing this in vane.

1

u/Low-Design787 Sep 19 '23 edited Sep 19 '23

Bing AI can sometimes give better hints than ChatGPT, and it shows you the pages it got the information so you can read the original human posts. Just keep it on GPT3.5, don’t use the 4 setting because that’s “creative”. In other words it just makes stuff up, which is great for writing pulp fiction, but not for programming!

You might also try GitHub Copilot which is specialised for this kind of thing. It’s paid, but you get 1 months free so you can try it out. It’s particularly useful when learning a new language. You use it via a Visual Studio Code plugin.

https://github.com/features/copilot

I think $10 a month is good value if it helps me learn something useful. And once you’ve learned Python, it also works with most other languages Rust, C#, Go, JavaScript, C++ etc.

It can help with R too.

1

u/Pericombobulator Sep 19 '23

I am no python wizard but started learning it over lockdown. I've also come from 20yrs of excel, with lots of involved spreadsheets under my wing.

I came from a long and distant history of Basic, so variables and loops were pretty intuitive. The bit I struggled with was syntax. When to use what bracket, mainly.

If you stick at it then you'll see Python is really just the framework that holds together all of the packages. Some of those are simple, but pandas is a massive subject. There are lots of good videos on YouTube that talk you through in great detail. I followed these, coding along

https://youtube.com/playlist?list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y&si=J9CLn9MkoijY-gA8

Definitely use Jupyter notebooks as they make the data wrangling interactive.

1

u/grumble11 Sep 19 '23

If I were you I would consider redoing all of the courses without any help from AI whatsoever. Try to use SO as little as possible also. The reason is that they have stolen your learning. You need to actually bash your head against this problem until you figure it out - it is the only way to really internalize the learning. Chat GPT is NOT a tool to be used to solve exercises for you during a course.

I agree that I hate video as well. Give me text and interactive exercises.

For pandas, if I were you I would literally download a few datasets off of kaggle and then I would go through the entire pandas API, first series, then data frames, then plotting. Every single function. Try it out in a script and use it a few different ways or understand the potential arguments. Then after that take a pandas course to understand best practices.

Pandas is tough, the syntax can be inconsistent (when parentheses? When brackets? When will nesting work versus not work?) and wrangling data can be hard. You’ll need a couple gos at it and a lot of practice.

1

u/2bereallyhonest Sep 19 '23

Because it is... there's a million plug ins and side programs and about a hundred ways to make a program work that's part of the fun and part of the frustration

1

u/CaptainFoyle Sep 19 '23

Do an introductory course to get the basics straight

14

u/[deleted] Sep 18 '23

[removed] — view removed comment

2

u/Sonoshitthereiwas Sep 18 '23

Ahm, given that it is hard, a course on this could help tremendously. You can search for courses or book related to data analysis or pandas itself, and it will help you tons.

"I'm going back through and trying to recreate much of the items we went over to make sure I 'get it'." This makes me think that the courses you're looking at are not deep enough, or didn't give enough examples for you to work with, this makes learning harder to do!

The course (it was actually 10 courses in DataCamp)was not meant to make anyone an expert. The way DataCamp works is it has about 5 minute video explaining something and then you do it. The problem I have is I don’t learn well from videos. But the course had a timeline to complete, so I completed the course. About 40 in total of those.

Now, I’m actually going back through using the transcripts to read what we did and then recreate it. I just went back through the first one and realized I completely missed how you can only use certain things with certain objects, like using .index() or .count() works with a list versus capitalize() or replace() works with str. Because it was a video and I don’t process audio well I completely missed it.

Besides that, there's also the aspect that you're learning to use a new programming language too, and, if you don't know it, you're bound to go slow and sometimes do things by trial and error, or by copying an answer that works somewhere else, so this is another painful point.

You’re right. And the reminder is a good one. Im just use to being “the nerd” in the room, and it’s a struggle to be the slow one.

"that basically means I need a separate log of anything I'm doing before I do anything" - that is very common, I do it almost every day, and the more complex or the less I know about something, the more I do it! So, it's normal, don't worry.

This makes me feel a little better 😅

• ⁠Ah! And, if you aren't interested in Python per se, but only dealing with data, I recommend R, which is very intuitive to use (tidyverse... chef's kiss) and in my opinion has a smoother learning progression than pandas itself. R is a language specifically designed for data, so it shines in this aspect!

Unfortunately, I’m in a Master program that uses Python which is why we’re learning it. Most of the people I’m in class with already have experience with it, at least to a small degree. Im a fair bit older than most of my ‘classmates’, so trying to do a kind of catch up.

Im hoping understanding Python will translate to helping me learn R after this program.

PS: About the keeping track of things, use Jupyter notebooks if you're not doing so yet. And, if the data is not clean, the first step is usually understanding what is not clean and then dealing with it.

Im using Anaconda, and Jupiter is in there, I just haven’t touched it yet. I was thinking I’d learn and practice the basics first, then jump into Jupiter. Maybe I’m trying to jump ahead without realizing it.

Cheers, and good luck on your journey!

Thanks 🙏

0

u/[deleted] Sep 19 '23

[deleted]

1

u/Sonoshitthereiwas Sep 19 '23

Well, kind of lol. At the bottom of the screen, when watching a video, on the right it has a green 'Got It!' button. On the opposite side, or far left, it has 'Show Transcript'.

I clicked Show Transcript on each video and then just pasted it onto a word document. I'm now going back through that and editing it down to just what I need. Like deleting all of the 'Hi, I'm so and so'. These are all the ones I did it for:

Introduction to Python

Intermediate Python

Python Data Science Toolbox (Part 1)

Python Data Science Toolbox (Part 2)

Writing Efficient Python Code

Writing Efficient Code with pandas

Writing Functions in Python

Software Engineering Principles in Python

Unit Testing for Data Science in Python

Object-Oriented Programming in Python

0

u/[deleted] Sep 19 '23

[deleted]

1

u/Sonoshitthereiwas Sep 19 '23

I just sent them a message asking if it was ok to share, if they come back and say yes, then I’ll be happy to share.

4

u/[deleted] Sep 18 '23 edited Sep 18 '23

[removed] — view removed comment

2

u/Sonoshitthereiwas Sep 19 '23

Thanks much, it really is very appreciated

1

u/Past-T1me Sep 19 '23

Also reinforcing the point to use Jupiter notebook, it makes things so much easier. If you have git bash, you just right click where you want to open it(like a work folder) type Jupiter notebook in the git console and it opens up folder/files in a UI you just click which you want open. Jupiter also has cells that lets you run completed blocks of code whenever you want. Really helps for trying to figure out where something went wrong and isolating that piece.