简体   繁体   English

如何使用 python 从 DataCamp 导出数据?

[英]How can I export data from DataCamp by using python?

I use DataCamp for the online learning of Python.我使用 DataCamp 进行 Python 的在线学习。 Sometimes I would like to export the data used in the exercises, but I can't find an easy way to do so.有时我想导出练习中使用的数据,但找不到简单的方法。

I know that there are instructions for downloading the videos or slides, and some courses provide some selected datasets for download in the course description.我知道有下载视频或幻灯片的说明,有些课程在课程描述中提供了一些选定的数据集供下载。 But how do I download data that I can access through the DataCamp exercise interface for export outside of the platform?但是如何下载可以通过DataCamp练习界面访问的数据,导出到平台外呢? Sometimes, the data used in the tutorial is processed and unmatched with the original data I download on the course page.有时,教程中使用的数据经过处理,与我在课程页面上下载的原始数据不匹配。 Oftentimes, I need to do reverse engineering to make the local data as same as the data in the course interface before running my code and trying different things in my local environment, and it takes me a lot of time.很多时候,在运行我的代码并在我的本地环境中尝试不同的东西之前,我需要做逆向工程使本地数据与课程界面中的数据相同,这需要我花费大量时间。

I tried pandas.DataFrame.to_csv , but I couldn't find the exported data if there was one.我试过pandas.DataFrame.to_csv ,但如果有导出的数据,我找不到。

I saw some can do this when learning R. Is there the same thing we can do in Python courses?我看到有些人在学习 R 时可以做到这一点。我们在 Python 课程中可以做同样的事情吗?

write.csv or dput in R write the dataframe to the console (and then you need to copy / paste the text to turn it into a csv. R 中的write.csvdput将数据帧写入控制台(然后您需要复制/粘贴文本以将其转换为 csv。

If you want to do something similar you could try如果你想做类似的事情,你可以尝试

no_rows = len(df) # number of rows of dataframe

pd.options.display.max_rows = no_rows

Depending on the no.取决于编号。 of rows this can take a while and the copy/paste activity is quite cumbersome.行这可能需要一段时间,复制/粘贴活动非常繁琐。 A better approach might be to just extract a few rows so you understand the structure of the dataframe that's been processed in order to run the code with your own datasets (simulated or different ones).更好的方法可能是只提取几行,以便您了解已处理的数据帧的结构,以便使用您自己的数据集(模拟或不同的数据集)运行代码。

df.to_csv() gives you a string you can copy into your local editor. df.to_csv()为您提供一个字符串,您可以将其复制到本地编辑器中。 Then look for \\\\n and replace all with \\n .然后查找\\\\n并用\\n替换所有内容。 Save your file as csv.将文件另存为 csv。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 Python 中的数据导出到 .txt? - How can I export data from Python to .txt? 如何将数据从 Python 导出到 a.csv 文件? - How can I export data from Python to a .csv file? 如何从 Zendesk 导出数据? - How can I export data from Zendesk? 如何使用Pandas将python Web抓取数据导出到现有excel文件中的特定工作表? - How can I export my python web scrape data to a specific sheet in an existing excel file using pandas? 如何通过STDOUT从Python子进程命令导出二进制数据? - How can I export binary data from Python subprocess command through STDOUT? 如何使用 python 将变量从 .mat 文件(由 Dymola 生成)导出到 .csv - How can I export variables from .mat file (generated by Dymola) to .csv using python 如何使用 python 将 JSON 数据导出到 CSV? - How do I export JSON data to CSV using python? 如何使用 Python 将 VirtualBox 机器导出到 OVA 设备? - How can I export a VirtualBox machine to OVA appliance using Python? 如何使用python从GUI可执行文件导出数据 - How to export data from a GUI executable using python 如何使用For Loops将数据从Excel导出到Python? - How do you export data from Excel into Python using For Loops?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM