Lau*_*ref 6 python dataframe pandas anaconda
我是新手使用熊猫,我只是不知道该怎么做:
我正在使用python.我(正确)安装了anaconda.在我的文件中,我只是创建一个DataFrame(首先从read_csv导入它,然后手动重新创建它以确保不是问题).当我打印(数据帧)时,它打印:
km | price
0 | 240000 | 3650
[...]
23 | 61789 | 8290
Run Code Online (Sandbox Code Playgroud)
当我做dataframe.info()时我得到了这个:
class 'pandas.core.frame.DataFrame'
Int64Index: 24 entries, 0 to 23
Data columns (total 2 columns):
km 24 non-null int64
price 24 non-null int64
dtypes: int64(2)
memory usage: 576.0 bytes
Run Code Online (Sandbox Code Playgroud)
哪个是完美的.但我尝试的任何其他简单功能只显示NOTHING.我尝试了dataframe.head(),dataframe ['km'],dataframe [3:6]等.没有错误,我的终端上只有一大碗什么都没有.
编辑以添加示例代码:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
pd.set_option('max_columns', 50)
#df=pd.read_csv('data.csv')
data = {'km': [240000, 139800, 150500, 185530, 176000, 114800, 166800, 89000, 144500, 84000, 82029, 63060, 74000, 97500, 67000, 76025, 48235, 93000, 60949, 65674, 54000, 68500, 22899, 61789], 'price': [3650, 3800, 4400, 4450, 5250, 5350, 5800, 5990, 5999, 6200, 6390, 6390, 6600, 6800, 6800, 6900, 6900, 6990, 7490, 7555, 7990, 7990, 7990, 8290]}
df = pd.DataFrame(data, columns=['km', 'price'])
print (df)
df.info()
df[2:5]
df["km"]
Run Code Online (Sandbox Code Playgroud)
小智 24
你必须使用:
print(dataframe.head())
print(dataframe['km'])
print(dataframe[3:6])
Run Code Online (Sandbox Code Playgroud)
如果没有print语句,python只是选择数据但不对它做任何事情.
| 归档时间: |
|
| 查看次数: |
15275 次 |
| 最近记录: |