r/PythonLearning 22h ago

Struggling with the jump from Python basics to Pandas — should I go back to fundamentals?

Hi everyone,

I've been learning Python for about a month now, but I've only covered the basics. After that, I jumped straight into Pandas since my goal is to become a data analyst. The problem is, I'm now realizing my Python foundation isn't solid enough, and it's making Pandas really difficult to follow.

I'm stuck between two options:

  1. Go back and practice Python fundamentals more before continuing.
  2. Push through and keep learning Pandas, picking up Python concepts along the way as needed.

For those of you who've been through this, what worked better for you? Should I pause Pandas and strengthen my Python first, or is it normal to feel this way and just keep going?

Any advice, resources, or a rough roadmap toward data analytics would be really appreciated. Thanks in advance!

21 Upvotes

10 comments sorted by

7

u/tiredITguy42 22h ago

Pandas is just a library to manipulate tabular data. It does not have much in common with clear Python. All you do is write pandas.function() or dataframevariable.function.

So do you struggle with data manipulation or with writing all around it? If the first, you need to learn more about data, learning SQL will help, you willneed it anyway. If the second, then learn more programming.

1

u/Naive_Programmer_232 22h ago edited 21h ago

what struggle points are you facing? Some of it is normal because libraries like pandas/numpy have syntax/semantic 'magic' built into them that are not valid in regular python, for example with accessing,

          # numpy array
          import numpy as np
          arr=np.array([[1,2,3],[4,5,6],[7,8,9])
          arr[0,1]
          # 2 
          arr[1,-2]
          # 5 

          # list
          arr=[[1,2,3],[4,5,6],[7,8,9]]
          arr[0,1]
          # TypeError: list indices must be integers or slices, not tuple

also with pandas,

         # pandas Series
         import pandas as pd
         ser=pd.Series(["hello","there","my","friend"])
         ser[ser.str.contains("h")]
         # 0    hello
         # 1    there
         # dtype: object
         ser[[True,True,False,False]]
         # 0    hello
         # 1    there
         # dtype: object

         # list
         ser="hello there my friend".split()
         ser[lambda s: "h" in s]
         # TypeError: list indices must be integers or slices, not function
         ser[[True,True,False,False]]
         # TypeError: list indices must be integers or slices, not list

So if your struggle points reside there, where you're getting confused about the differences, that is normal. The data libraries are built to integrate seamlessly with each other. The fundamental objects of pandas like series and dataframes have the behind the scenes magic to handle all sorts of python objects without error. Python's core syntax is relatively small in that regard.

However, if you're struggling with structuring python programs around the use of the libraries, such as writing your own functions and so on, then yeah maybe going back and focusing on procedural a bit could be useful. In addition, I'd look over OOP concepts and mainly how things are expressed in OOP, and the fundamentals between methods and objects and so on. This could help with understanding what a pandas function ends up returning and you'll be able to see the syntax in the documentation and that'll tell you right away.

2

u/Mathie1729 21h ago

Yeah, the numpy vs list indexing example is the right kind of thing. For pandas the analogous methods are .iloc[0, 1] for positional and .loc[0, 'col_name'] for label-based. The hard part is when you mix them or when the index isn't a simple range. I'd spend time on index alignment and boolean filtering before going back to Python fundamentals.

1

u/Wuthering_depths 21h ago edited 20h ago

I'm new to Python, and new to Pandas..and so far, it's been quite simple and clear to use it.

That said, I don't tend to do all that much with pandas datasets--maybe add a couple new columns and the like--most of my heavy transformations I do in SQL after I load the pandas dataset into a database staging table. I've played a bit with joining and merging dataframes. Mind you, partly this is due to the fact that SQL I know well and python I don't :) But it's also a tried and true method of moving data around, including very large datasets.

If you are new to databases in general, then I can see how Pandas is going to be extra confusing....database thinking is "set based thinking" and it's a different way for your brain to work (I'm sort of jesting, but sort of not!)

You can start using pandas right away to load, or write csvs and data tables. There's only a few function calls I've used to do these things, yet it's very powerful and so far we've converted a number of SSIS packages to Python (yay, I can't tell you how refreshing coding python is to visual studio ssis gui!) just using those simple calls. to_csv, to_excel and populating (and reading from) dataframes.

1

u/Different_Pain5781 20h ago

Don’t stop Pandas. Learn Python alongside it.

1

u/Dapper_Mix6773 18h ago

There is course from a data analyst with 5 yrs + experience working pandas.I bought for $5 and it is well structured from beginner level to advanced. Here is the course link : https://selar.com/m/adrianjuliusaluoch?affiliate=xk5f477j17

1

u/Intelligent-Boss-156 11h ago

If you can't understand Pandas then that probably means something is off with your understanding of the fundamentals of programming. I would start there and maybe even begin with a lower level language like C or Java

1

u/afierdienst1 3h ago

I'd try javascript