May 6, 2020 at 12:00 am
Comments posted to this topic are about the item Getting Dataframe Metadata
May 6, 2020 at 3:59 am
I'm sorry, but your explanation is incorrect. Numpy.info, to which you refer, is a numpy-specific help function that does not give such an output about the data frame that is in your explanation. This informations are given by the Pandas DataFrame info() function.
Here is a simple example:
import pandas as pd
data = [['Alex',10],['Bob',12],['Clarke',13]]
df = pd.DataFrame(data,columns=['Name','Age'])
print df
df.info()
print'--------------------------------------------------------------------'
#Import numpy for np.info (df)
import numpy as np
print 'Output from np.info():'
print'--------------------------------------------------------------------'
np.info(object = df)
Results:
$python main.py
Name Age
0 Alex 10
1 Bob 12
2 Clarke 13
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3 entries, 0 to 2
Data columns (total 2 columns):
Name 3 non-null object
Age 3 non-null int64
dtypes: int64(1), object(1)
memory usage: 120.0+ bytes
--------------------------------------------------------------------
Output from np.info():
--------------------------------------------------------------------
Two-dimensional size-mutable, potentially heterogeneous tabular data
structure with labeled axes (rows and columns). Arithmetic operations
align on both row and column labels. Can be thought of as a dict-like
container for Series objects. The primary pandas data structure
Parameters
----------
data : numpy ndarray (structured or homogeneous), dict, or DataFrame
Dict can contain Series, arrays, constants, or list-like objects
index : Index or array-like
Index to use for resulting frame. Will default to np.arange(n) if
no indexing information part of input data and no index provided
columns : Index or array-like
Column labels to use for resulting frame. Will default to
np.arange(n) if no column labels are provided
dtype : dtype, default None
Data type to force, otherwise infer
copy : boolean, default False
Copy data from inputs. Only affects DataFrame / 2d ndarray input
Examples
--------
>>> d = {'col1': ts1, 'col2': ts2}
>>> df = DataFrame(data=d, index=index)
>>> df2 = DataFrame(np.random.randn(10, 5))
>>> df3 = DataFrame(np.random.randn(10, 5),
... columns=['a', 'b', 'c', 'd', 'e'])
See also
--------
DataFrame.from_records : constructor from tuples, also record arrays
DataFrame.from_dict : from dicts of Series, arrays, or dicts
DataFrame.from_items : from sequence of (key, value) pairs
pandas.read_csv, pandas.read_table, pandas.read_clipboard
May 6, 2020 at 9:13 am
Nice question, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
May 6, 2020 at 2:51 pm
Apologies, corrected the reference.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply