简体   繁体   中英

Is a pandas dataframe a list of lists?

I just learned some basics of pandas today, and I notice that pandas dataframes look very similar to when you run the same csv file using the csv module (which I recall can be treated as a list of lists). I can't seem to slice a pandas dataframe like a list of lists, but the dataframe['column name'] resembles what you do to extract values from dictionaries. So are pandas dataframes like dictionaries, but the values of its keys are lists?

You can consider a dataframe as a dictionary of Series (both on construction and on lookup), but there are plenty facilities to access rows too.

Under the hood a dataframe is decorated numpy array-like structure, as described here

As i said in my comment section, In general, you could say that the Pandas DataFrame consists of three main components: the data, the index, and the columns dictionaries of one-dimensional ndarray(structured or homogeneous)'s, lists, dictionaries or Series.

DataFrame

Dict can contain Series, arrays, constants, or list-like objects

Changed in version 0.23.0: If data is a dict, argument order is maintained for Python 3.6 and later.

look at here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM