python中dtypes_Dataframe创建及index,columns,values,dtypes等属性介绍

DataFrame概念(可以通俗理解为excel中一片数据)

表格型数据结构,带有标签的二维数组,有行标签(index)和列标签(columns),其值可以是数值、字符串、布尔值等。

1、.index 行标签

2、.columns 列标签

3、.values 值

.4、dtypes return the dtypes in the DataFrame.

– coding: utf-8 –

import pandas as pd

d = {‘col1’: [1, 2], ‘col2’: [3, 4]}

df = pd.DataFrame(data=d)

print(df)

print(df.index)

print(df.columns)

print(df.values)

print(df.dtypes)

D:python3installpython.exe D:/python/py3script/test.py

col1 col2

0 1 3

1 2 4

RangeIndex(start=0, stop=2, step=1)

Index([‘col1’, ‘col2′], dtype=’object’)

[[1 3]

[2 4]]

col1 int64

col2 int64

dtype: object

Process finished with exit code 0

一:数组/list组成的字典创建DataFr

Original: https://blog.csdn.net/weixin_42491590/article/details/114409438
Author: 待空后成疯
Title: python中dtypes_Dataframe创建及index,columns,values,dtypes等属性介绍

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/676414/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球