提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加
例如:第一章 Python 机器学习入门之pandas的使用
提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录- 系列文章目录
- 前言
- 一、环境
- 1.使用vagrant快速创建linux虚拟机
- 二、使用步骤
- 1.引入库
- 2.读入数据
- 总结
前言
提示:这里可以添加本文要记录的大概内容:
提示:以下是本篇文章正文内容,下面案例可供参考
一、环境示例:pandas 是基于NumPy 的一种工具。
1.使用vagrant快速创建linux虚拟机1.下载virtualbox 安装包已有
要开启cpu虚拟化
安装目录: D:javaruanjian01samllOracleVirtualBox
安装VirtualBox,建议安装最新的版本!默认安装到D盘,一直点下一步。安装前以及安装过程中,保证 我的电脑——右击——管理——服务和应用程序——服务——在服务里启动:
1,Device Install Service.
2, Device Setup Manager.
这两个服务启动后,在安装,安装过程中很有可能还会失败,因为这两个服务会终止。所以请在进度条卡住时(应该是在安装驱动…),赶快重启以上服务,这样可以确保安装成功
- 下载vagrant 安装包已有
默认D盘,一直点下一步,重启电脑,win+R键 cmd 输入vagrant 验证是否安装成功
安装目录: D:javaruanjian01samllHashiCorpVagrant - 使用vagrant 快速在 virtualBox 里面创建虚拟机
vagrant官方镜像仓库
安装centos7,创建虚拟环境。win+R键 cmd 输入 vagrant init centos/7。在C:Usersadmin 创建了一个Vagrantfile
启动虚拟环境:在 cmd 输入 vagrant up。如果不成功进行以下 *** 作: 重启后在 cmd 输入 vagrant up --provider=virtualbox
输入:vagrant up 命令时,提示如下信息 No usable default provider could be found for your system. Vagrant relies on interactions with 3rd party systems, known as "providers", to provide Vagrant with resources to run development environments. Examples are VirtualBox, VMware, Hyper-V. The easiest solution to this message is to install VirtualBox, which is available for free on all major platforms. If you believe you already have a provider available, make sure it is properly installed and configured. You can see more details about why a particular provider isn't working by forcing usage with `vagrant up --provider=PROVIDER`, which should give you a more specific error message for that particular provider. 遇到上面的情况,说明需要指定一个提供者, 在指定一个提供者时,输入:vagrant up --provider=virtualbox 等号后面的名称根据提前装载的virtualbox填写 又提示下面的信息,说明vagrantbox的版本不再它显示的版本中, The provider 'centos/7' could not be found, but was requested to back the machine 'default'. Please use a provider that exists. Vagrant knows about the following providers: docker, hyperv, virtualbox vagrant up --provider=virtualbox The provider 'virtualbox' that was requested to back the machine 'default' is reporting that it isn't usable on this system. The reason is shown below: Vagrant has detected that you have a version of VirtualBox installed that is not supported by this version of Vagrant. Please install one of the supported versions listed below to use Vagrant: 4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0 A Vagrant update may also be available that adds support for the version you specified. Please check www.vagrantup.com/downloads.html to download the latest version. 然后在本地找plugin.rb、meta.rb文件进行修改 E:HashiCorpVagrantembeddedgems2.2.6gemsvagrant-2.2.6pluginsprovidersvirtualboxplugin.rb 修改这个文件,plugin.rb文件增加红色部分 module Driver autoload :meta, File.expand_path("../driver/meta", __FILE__) autoload :Version_4_0, File.expand_path("../driver/version_4_0", __FILE__) autoload :Version_4_1, File.expand_path("../driver/version_4_1", __FILE__) autoload :Version_4_2, File.expand_path("../driver/version_4_2", __FILE__) autoload :Version_4_3, File.expand_path("../driver/version_4_3", __FILE__) autoload :Version_5_0, File.expand_path("../driver/version_5_0", __FILE__) autoload :Version_5_1, File.expand_path("../driver/version_5_1", __FILE__) autoload :Version_5_2, File.expand_path("../driver/version_5_2", __FILE__) autoload :Version_6_0, File.expand_path("../driver/version_6_0", __FILE__) autoload :Version_6_1, File.expand_path("../driver/version_6_1", __FILE__) end E:HashiCorpVagrantembeddedgems2.2.6gemsvagrant-2.2.6pluginsprovidersvirtualboxdrivermeta.rb 修改meta.rb这个文件,增加红色的部分 driver_map = { "4.0" => Version_4_0, "4.1" => Version_4_1, "4.2" => Version_4_2, "4.3" => Version_4_3, "5.0" => Version_5_0, "5.1" => Version_5_1, "5.2" => Version_5_2, "6.0" => Version_6_0, "6.1" => Version_6_1, } 在:E:HashiCorpVagrantembeddedgems2.2.6gemsvagrant-2.2.6pluginsprovidersvirtualboxdriver 增加一个新文件,文件名称:version_6_1.rb,内容如下: require File.expand_path("../version_6_0", __FILE__) module VagrantPlugins module ProviderVirtualBox module Driver # Driver for VirtualBox 6.1.x class Version_6_1 < Version_6_0 def initialize(uuid) super @logger = Log4r::Logger.new("vagrant::provider::virtualbox_6_1") end end end end end 然后在执行:vagrant up --provider=virtualbox Bringing machine 'default' up with 'virtualbox' provider... ==> default: importing base box 'centos/7'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: jmcentos7 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: bridged ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. The guest machine entered an invalid state while waiting for it to boot. Valid states are 'starting, running'. The machine is in the 'unknown' state. Please verify everything is configured properly and try again. 出现上面就成功了。 ———————————————— 版权声明:本文为CSDN博主「SpringClouds」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/chen_785/article/details/105613724
- 连接虚拟机 cmd 输入vagrant ssh 。
- 端口转发:设置网络环境 找到 C:Users593 的 Vagrantfile 文件打开 ,找到#config.vm.network “private_network”, ip: “192.168.56.10”
将上面那一行放开,并将ip改为 本机电脑的 Ip,win+R cmd ipconfig 找到virtualbox 的 ip 。
重启虚拟机 输入 vagrant reload,
停掉服务:ctrl + c,连接虚拟机:vagrant ssh, 在虚拟机看虚拟机网络地址:ip addr,在cmd里ping虚拟机地址:ping 192.168.56.10
查看哪个用户:whoami 所有目录: ls / 退出:exit;二、使用步骤 1.引入库
代码如下(示例):
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import warnings warnings.filterwarnings('ignore') import ssl ssl._create_default_https_context = ssl._create_unverified_context2.读入数据
代码如下(示例):
data = pd.read_csv( 'https://labfile.oss.aliyuncs.com/courses/1283/adult.data.csv') print(data.head())
该处使用的url网络请求的数据。
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)